Created
June 8, 2011 23:12
-
-
Save fnando/1015687 to your computer and use it in GitHub Desktop.
Switch block's context and yield variable. At the same time. How would you do it?
This file contains 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
object = Object.new | |
block = proc do |var| | |
puts "var: #{var.inspect}" #=> should be :a => 1 | |
puts "self: #{self.inspect}" #=> should be object variable | |
end | |
block.call :a => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment