Skip to content

Instantly share code, notes, and snippets.

@Jacke
Created July 7, 2013 22:45
Show Gist options
  • Select an option

  • Save Jacke/5945261 to your computer and use it in GitHub Desktop.

Select an option

Save Jacke/5945261 to your computer and use it in GitHub Desktop.
Block as closure
def method_with_block_as_closure(&block)
another_method block
end
def another_method(variable)
m2 &variable
end
def m2
x=25
yield x
end
method_with_block_as_closure {|i| print "I am happy block #{i}"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment