-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Set multiple fields at once in some sort of pipe? #15
Comments
Yes, would be nice to have this, see also jw3126/Setfield.jl#80 |
This is already (partially) supported, by the way: julia> @set n[(:a, :b)] = (4, 100)
(a = 4, b = 100, c = 3) Also see |
Also just stumbled over this. Has there been any work on this feature? |
Not really, for me personally |
Agree, Aside from the potential implementation itself, it's not obvious what the general interface should look like. Stuff like "set |
Depending on the specific usecase, a recent feature of AccessorsExtra can be useful: julia> o = @optic₊ (_.a, _.b)
julia> set(n, o, (4, 100))
(a = 4, b = 100, c = 3) Isn't much of a win for single-use (is it even possible to make shorter syntax?), but can help when reusing the optic in multiple occasions. |
This seems to be the oldest open issue on the topic, best to consolidate any potential discussion in one place. Others are #119 and #82. A rough summary of the current understanding:
More practically, for now:
julia> using Accessors, DataPipes
julia> nt = (a=1, b=2)
julia> @p let
nt
@set __.b = 3
@set __.a += 4
@insert __.c = 9
@set √(last(__)) += 1
end |
It would be nice to be able to do
The text was updated successfully, but these errors were encountered: