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 I actually favor a third approach; keyword argument options. OrderHash.new(:auto? => true) I think Rails has shown us that such option hashes are extremely powerful and flexible. Just my $.02 Daniel