From: Brian Candler Date: 2002-10-17T18:06:31+09:00 Subject: Re: Precompiling eval expressions On Thu, Oct 17, 2002 at 06:36:02AM +0900, Nikodemus Siivola wrote: > Like this? > > code = "puts 'foo'" > o = Object.new > o.instance_eval "def bar;#{code};end" > o.bar Ah, some things falling into place now :-) I can add methods to an individual object, rather than to a class; so I get a sort of private derived class (i.e. o is no longer really an "Object" but an "Object plus some stuff", although o.type still says "Object") Would o.bar be correctly termed a "singleton method"? If so, I think that's one of the few areas where Programming Ruby creates confusion. As far as I can see, the only use of the term 'Singleton' in the first exposition is for creating single instances of a class (i.e. the Singleton mixin), and later on singleton methods are just mentioned in passing as if you knew about them already... Thanks, Brian.