From: Phrogz Date: 2006-10-21T22:35:17+09:00 Subject: Re: instance_eval && class_eval Artur Merke wrote: > so why is > D.i_method wrong and > D.new.i_method correct? I'm not surprised by that. I'm surprised that standard def...end syntax inside instance_eval behaves differently from being in the class scope, when the self object in both cases is the same. irb(main):001:0> class Foo irb(main):002:1> p "Defining aa in #{self}##{self.object_id}" irb(main):003:1> def aa; p :aa; end irb(main):004:1> instance_eval{ irb(main):005:2* p "Defining bb in #{self}##{self.object_id}" irb(main):006:2> def bb; p :bb; end irb(main):007:2> } irb(main):008:1> end "Defining aa in Foo#1699170" "Defining bb in Foo#1699170" => nil irb(main):009:0> Foo.new.aa :aa => nil irb(main):010:0> Foo.bb :bb => nil