From: Sebastian Hungerecker Date: 2007-11-04T05:48:11+09:00 Subject: Re: x=[:some_key] does not work? Lionel Bouton wrote: > For a 2-dimensional Hash you can use: > > h = Hash.new({}) That won't result in the behaviour most people would expect from a 2-dimensional hash: >> h = Hash.new({}) => {} >> h[:a][:foo] = "bar" => "bar" >> h[:a] => {:foo=>"bar"} >> h => {} >> h[:b][:chunky] = "bacon" => "bacon" >> h[:b] => {:chunky=>"bacon", :foo=>"bar"} >> h[:c] => {:chunky=>"bacon", :foo=>"bar"} >> h => {} You want to a) use the block-form of Hash.new to not use the same instance of a hash everytime and b) assign the new Hash instead of just returning it. -- Jabber: sepp2k@jabber.org ICQ: 205544826