Created
March 20, 2009 11:50
-
-
Save davidlee/82329 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 | |
| end | |
| class Flibby | |
| def make_method( _method_name ) | |
| puts _method_name | |
| Foo.class_eval do | |
| puts _method_name | |
| class << self | |
| define_method _method_name do | |
| puts "yay" | |
| end | |
| end | |
| end | |
| end | |
| end | |
| Flibby.new.make_method "wibble" | |
| [ 22:50 ][ dml@shifter ] % ruby ~/test.rb | |
| wibble | |
| wibble | |
| /home/dml/1.rb:10:in `make_method': undefined local variable or method `_method_name' for #<Class:Foo> (NameError) | |
| from /home/dml/1.rb:7:in `class_eval' | |
| from /home/dml/1.rb:7:in `make_method' | |
| from /home/dml/1.rb:18 | |
| zsh: exit 1 ruby ~/1.rb |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment