On Jul 14, 2006, at 7:58 PM, transfire / gmail.com wrote: > Jan Molic recently contacted me about a slighlty modified version of > his OrderedHash class that I distribute in Facets, the Dictionary > class. There are a few variations of this class initself and Jan > originally provided these via a subclass. I, on the other, thought > alternate initializers would be better. > > Which is the best approach? > > Ex. > > class AutoOrderHash < OrderedHash > > def new(*args) > super(*args){ |h,k| h[k] = self.class.new } > end > > end > > vs. > > class OrderHash > > def self.auto(*args) > new(*args){ |h,k| h[k] = self.class.new } > end > > end > > Thanks, > T. > > The second implemented in terms of the first? class OrderHash def self.auto(*args) AutoOrderHash.new(*args) end end Yes, please have your cake and eat it too. :)