Created
January 13, 2011 21:08
-
-
Save ymendel/778607 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
>> 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