From: Joel VanderWerf Date: 2005-07-25T05:05:55+09:00 Subject: Re: Using a class namespace for subclasses Timothy Hunter wrote: > Trans wrote: > >> Wondering the general feeling about using the class namespace for >> subclasses. Basically I have a number of specialized Hash classes: >> OrderedHash, SyncHash, StaticHash. But I'm thinking it might be more >> elegant to name them: Hash::Ordered, Hash::Sync, Hash::Static. Is that >> a better way to go or no? >> >> Thanks, >> T. >> > Use a module to contain the classes: > > module Hash > class Ordered > ... > end > class Sync > ... > end > class Static > ... > end > end > > myhash = Hash::Ordered.new irb(main):001:0> module Hash; end TypeError: Hash is not a module from (irb):1 but "class Hash" works. I think the OP was asking whether this approach--using the Hash namespace--which seems more elegant, might have some drawbacks. It might set you up for some conflicts with constants other code defines in the Hash namespace.