From: "ara.t.howard" Date: 2008-10-23T12:02:29+09:00 Subject: Re: subclass a class in the namespace of the that subclass On Oct 22, 2008, at 3:53 PM, Trans wrote: > I know it may seem a bit off the wall. But I want to subclass a class > that is also defined in the namespace of the subclass. In other words: > > class X < Y > class Y > end > end > > Why do I want to do this? Because my library (X) consists of a few > components, one of them being Y. And I want the end user of the > library to use it by typing "X.new". Now, X is all but the same as Y, > with only with some minor adjustments. > > Unfortunately for me there seems to be no way to do this without Ruby > complaining of a superclass mismatch. invert: cfp:~ > cat a.rb class Y def Y.foo() 42 end class ::X < Y Y = Y end end p(Y == X::Y) p X.foo cfp:~ > ruby a.rb true 42 a @ http://codeforpeople.com/ -- we can deny everything, except that we have the possibility of being better. simply reflect on that. h.h. the 14th dalai lama