Skip to content

Instantly share code, notes, and snippets.

@vic
Created October 11, 2010 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vic/620652 to your computer and use it in GitHub Desktop.
Save vic/620652 to your computer and use it in GitHub Desktop.
# 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