From: matt@... (matt neuburg) Date: 2009-04-04T03:09:29+09:00 Subject: Re: Class in a Class problem Robert Klemme wrote: > > class A > > def b > > Class.new do > > def initialize(a) > > @a = a > > end > > attr :a > > end.new(self) > > end > > # other stuff that an A knows how to do > > end > > You are creating new classes all the time. I don't think this is a good > idea. I'm not sure what you mean about new *classes*. It is certainly true that I didn't do anything prevent the user from calling "b" twice on the same A instance, thus getting two different objects pointing at that instance: a = A.new b = a.b # b is an instance whose "@a" points at "a" bb = a.b # bb is a different instance whose "@a" points at "a" But that's easy to solve if desired. Obviously the real problem here is that I couldn't fathom what the OP was actually trying to *do*. m. -- matt neuburg, phd = matt@tidbits.com, http://www.tidbits.com/matt/ Leopard - http://www.takecontrolbooks.com/leopard-customizing.html AppleScript - http://www.amazon.com/gp/product/0596102119 Read TidBITS! It's free and smart. http://www.tidbits.com