"Gavin Kistner" <gavin / refinery.com> schrieb im Newsbeitrag news:991b24e67ac5d4902f4b04192210830a / refinery.com... > On Feb 10, 2005, at 6:41 AM, Glenn Parker wrote: > > Robert Klemme wrote: > >> class << self;self;end.class_eval do > > > > This particular trick has shown up a lot on the Ruby list lately. > > It's kind of ugly, but clearly useful. I think it deserves a name, or > > possibly a new keyword. What would you call it, "virtual_class_eval"? > > Apparently I haven't been paying attention. What does the above do, and > how does it differ from: > > class Foo > def self.add( meth, &block ) > self.class_eval{ define_method( meth, &block ) } > end > end > > or > > class Foo > def add( meth, &block ) > self.class.class_eval{ define_method( meth, &block ) } > end > end > > ? > > Is it to add new methods to the instance only, and not all instances > derived from Foo? Exactly. robert > -- > (-, /\ \/ / /\/ > > >