From: Paul Lutus Date: 2006-10-27T06:10:11+09:00 Subject: Re: newbie q on class Foo::Bar matt neuburg wrote: > What's the point of a class-within-a-class? For example, I take it that > I can say: > > class Foo > class Bar > def whatever > ... > > And then I can say > > my_foo_bar = Foo::Bar.new > > For example, isn't that what something like File::Stat is? > > My question is, am I right about this, and if so, what's the point of > doing so? I take it that Bar is not magically related to Foo - it can't > see Foo's methods or anything like that, can it? So is this merely a way > of using a class (Foo) as a namespace so that related classes (like Bar) > are all in one place? Thx - m. One reason is to create a class that is private. You may be aware that one wants to separate results from implementation (separate the result from the method used to produce the result), this can extend to classes that need to exist, but don't need to be made available as part of the interface. That way, the programmer can change the class without having to ask what external effects this might have. There are other reasons, this is just one. -- Paul Lutus http://www.arachnoid.com