Re:Why blocks make Ruby methods slower
by jph on Friday February 27, 2015 @02:59PM
(#9120959)
Make it faster by replacing the block parameter with a comment:
- def a(&block)
+ def a #&block
This works when a method uses `yield` and doesn't do more with the block parameter.
Ideally Ruby would have a way to write a method signature to indicate a block is expected and/or or a yield happens, all without triggering the transformation of the block into a first class object.
Ideally Ruby would have a way to write a method signature to indicate a block is expected and/or or a yield happens, all without triggering the transformation of the block into a first class object.