Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >> 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
Add Comment
Please, Sign In to add comment