Skip to content

Instantly share code, notes, and snippets.

@ymendel
Created January 13, 2011 21:08
Show Gist options
  • Save ymendel/778607 to your computer and use it in GitHub Desktop.
Save ymendel/778607 to your computer and use it in GitHub Desktop.
>> class Blah
>> def callback(&b) @block = b; end
>> def do_it; @block.call; end
>> end
=> nil
>> b = Blah.new
=> #<Blah:0x511580>
>> n = 10
=> 10
>> b.callback { puts n }
=> #<Proc:0x0050cc38@(irb):17>
>> b.do_it
10
=> nil
>> n = 5
=> 5
>> b.do_it
5
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment