From: Brian Candler Date: 2005-07-25T17:56:19+09:00 Subject: Re: Using a class namespace for subclasses On Mon, Jul 25, 2005 at 05:05:55AM +0900, Joel VanderWerf wrote: > > 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. True, but I think the only way to be 100% sure of avoiding that is to use a vendor namespace. module VanderWerf module Hash class Ordered; end end end or VanderWerf::Joel in case there are multiple VanderWerfs developing Ruby code :-) Actually a domain name or E-mail address would be better. Usually though, we just accept the risk. There's a risk that a future version of Ruby (as well as another 3rd party library) might introduce its own Hash::Ordered; equally, though, it might introduce OrderedHash. Regards, Brian.