Created
March 28, 2010 08:05
-
-
Save harukizaemon/346642 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
irb --> RUBY_VERSION | |
==> "1.9.1" | |
irb --> module M | |
module A | |
def execute(&block) | |
instance_eval(&block) | |
end | |
end | |
end | |
module N | |
class B | |
end | |
class C | |
include M::A | |
def with_instance_eval | |
execute { B.new } | |
end | |
def without_instance_eval | |
B.new | |
end | |
end | |
end | |
==> nil | |
irb --> c = N::C.new | |
==> #<N::C:0x00000101030750> | |
irb --> c.without_instance_eval | |
==> #<N::B:0x0000010101ff48> | |
irb --> c.with_instance_eval | |
NameError: uninitialized constant N::C::B |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment