Skip to content

Instantly share code, notes, and snippets.

@harukizaemon
Created March 28, 2010 08:05
Show Gist options
  • Save harukizaemon/346642 to your computer and use it in GitHub Desktop.
Save harukizaemon/346642 to your computer and use it in GitHub Desktop.
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