You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Ruby 3.1 introduced anonymous block forwarding. An anonymous block argument can be forwarded to another method call using & as block argument. This is effectively just syntax sugar for forwarding the block explicitly via a block that yields. So it's a bit more concise.
defbar(&)
foo(&)
end
equivalent to:
defbar(&)
foo { |*args| yield*args }
end
This feature would not be a huge thing, but a nice little convenience feature.
The text was updated successfully, but these errors were encountered:
At this point it is probably too late for us since a bare single splat in Crystal already indicates a lack of extra positional parameters.
I guess technically it would be unambiguous. If * us used as any anonymous forward anywhere in the body, it's a catch-all, otherwise not.
But that would be confusing when you can't tell from the signature. That's the same problem we currently have with blocks and yield, #8764).
Plus, it's simply unnecessary. You can just give it a name and use that. Requires no special syntax.
That's different with & of course because you can't give it a name and simply forward it that way. That would capture the block, turning it into a proc which won't work with yield then.
Ruby 3.1 introduced anonymous block forwarding. An anonymous block argument can be forwarded to another method call using
&
as block argument. This is effectively just syntax sugar for forwarding the block explicitly via a block that yields. So it's a bit more concise.equivalent to:
This feature would not be a huge thing, but a nice little convenience feature.
The text was updated successfully, but these errors were encountered: