From: Christoph Date: 2002-03-28T01:49:33+09:00 Subject: Re: Hash.new(Hash.new) doesn't use Hash.new as default value "ts" wrote in message news:200203271517.g2RFHfL07516@moulon.inra.fr... > >>>>> "Y" == Yukihiro Matsumoto writes: > > Y> It does not store the evaluated default value. > > Yes, you are right. Sorry for the misinformation Quoting from your and Matz's solutions back in January (search Google-news for `multi-dimensional Hash group:comp.lang.ruby') you have to write this as class MatzHash < Hash def default(key) self[key] = type.new # happy type-mutating;-)) end end class TsHash < Hash def initialize super do |l,r| self[r] = type.new end # super do |l,r| l[r] = type.new end # works too - which does not seem right too me # I guess Matz intended that the arguments # l,r take on the values key,value ... end end > > Y> Should it? > > It depend if you want that it work like a P language (not really a good > reference for me :-))) No arguments here;-)) /Christoph