Created
October 11, 2010 15:05
-
-
Save vic/620652 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In rubinius you can obtain the block given to a method | |
# without having to rely on &block syntax | |
# | |
# This is how they implement yield, by obtaining the block given to the method. | |
def some_method_that_takes_a_block | |
given_block = Rubinius.asm do |generator| | |
generator.push_block # pushed the current block into the stack | |
end | |
given_block.call # It's a BlockEnvironment instance | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment