3 ms·
The use case for this would be that it doesn't reify the block IOW doesn't allocate a proc to wrap the block. ... but that optimisation has already been made†
by lloeki 3y ago
The use case for this would be that it doesn't reify the block IOW doesn't allocate a proc to wrap the block.
... but that optimisation has already been made† (and IIRC it is too for *args and **kwargs that just get forwarded to calls), so it mostly exists for consistency with anonymous * and ** and valueless keys, as well as documentation (making it explicit that the method accepts a block right from the signature). Here's the discussion: https://bugs.ruby-lang.org/issues/11256 https://bugs.ruby-lang.org/issues/11256
I don't particularly like it given the style I like to use, but I can see how people using a certain different style would as their style would be more consistent and carry better intent.
Anyway the post linked from the OP has a more detailed rundown: https://zverok.space/blog/2023-11-24-syntax-sugar4-argument-forwarding.html https://zverok.space/blog/2023-11-24-syntax-sugar4-argument-...
† https://bugs.ruby-lang.org/issues/14045 https://bugs.ruby-lang.org/issues/14045