Created
November 23, 2012 08:41
-
-
Save cheald/4134560 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 Foo | |
| def value | |
| "Value" | |
| end | |
| def eval_stuff | |
| instance_eval &(Proc.new { puts value }) | |
| instance_eval &(Proc.new {|foo| puts foo.value }) | |
| instance_eval &(lambda {|x| puts x.value }) | |
| instance_eval &(lambda {|x| puts value }) | |
| end | |
| end | |
| Foo.new.eval_stuff |
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
| % ruby foo.rb | |
| Value | |
| Value | |
| Value | |
| Value |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment