From: Greg Weeks Date: 2007-11-17T18:29:11+09:00 Subject: Re: "instance_eval" (eg, sent to a class object) Xavier Noria wrote: > C = "Object" > > class String > C = "String" > end > > a = '' > a.instance_eval do > def c_in_block; C; end > end > > a.instance_eval < def c_in_string; C; end > EOS > > puts a.c_in_block # -> Object > puts a.c_in_string # -> String The more that I think about scoping in the context of closures define_method instance_eval module_eval eval the more confused I get. Alas, I've never seen a formal description of the Ruby execution model. There seems to be a current self and a current klass, but I don't know exactly how they are set and used. I'll just say here that your fine example can be simplified a little: a.instance_eval { C } -> "Object" a.instance_eval "C" -> "String" -- Posted via http://www.ruby-forum.com/.