From: Rick DeNatale Date: 2007-04-17T03:24:35+09:00 Subject: Re: about finding subclasses On 4/15/07, eden li wrote: > Dang, you beat me to it. I had typed up a similar response. Here's a > minor tweak though. > > On Apr 15, 4:02 pm, "Harold Hausman" wrote: > > ... the class < > class just for object obj." ... > > As far as I can tell, all objects (and thus all classes) already have > this singleton class. "class << klass; self; end" is just a way to > get at it. Well logically at least. For regular objects a singleton class isn't created until it's needed. So: a = "abc" #at this point there is no singleton class for the instance of String referenced by a def a.foo "foo" end #at this point it does, the singleton class was created to hold the method. Of course you can't ever see the lack of a singleton class, at least from ruby code, in order to do so requires an extension. Classes get their singleton classes when they are created. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/