From: "Christoph R." Date: 2003-09-18T00:15:37+09:00 Subject: Re: hash default value dblack@superlink.net wrote: .... >>i expected that myOtherHash would be {"blue"=>{"red"=>1}} > > > No, there's no autovivification in the Perl manner :-) This not quiet true (for 1.8) - see Guy's post. If you want full autovivification your best bet is to sub-class Hash --- class AutoVHash < Hash def initialize end def default(key) self[key] = self.class.new end end autovhsh = AutoVHash.new autovhsh[1][2][3] = 4 p autovhsh[1][2][3] # => 4 --- or if you like puzzles --- body = proc {|hsh,key| hsh[key] = Hash.new &body } autovhsh = Hash.new &body autovhsh[1][2][3] = 4 p autovhsh[1][2][3] # => 4 --- /Christoph