Created
February 4, 2010 14:24
-
-
Save tonini/294668 to your computer and use it in GitHub Desktop.
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
lambda { | |
hash = {} | |
Kernel.send :define_method, :say do |sentence, &block| | |
hash[sentence] = block | |
end | |
Kernel.send :define_method, :hello do |&block| | |
hash.each_pair do |sentence, say| | |
block.call sentence, say | |
end | |
end | |
}.call | |
say "hey dude!" do | |
12 > 2 | |
end | |
hello do |sentence, say| | |
object = Object.new | |
puts "#{sentence}" if object.instance_eval &say # hey dude! | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment