From: Robert Dober Date: 2007-02-16T15:25:21+09:00 Subject: Re: Hash.new({}) astonishment On 2/16/07, Marcello Barnaba wrote: > >> h = Hash.new({}) > => {} > >> h[:a][:b] = 1 You are assigning to the {}, gotten by the [:a] look at this irb#1(main):014:0> h[:a][:b]=42 => 42 irb#1(main):015:0> o => {:b=>42} irb#1(main):016:0> h => {} irb#1(main):017:0> irb#1(main):018:0* irb#1(main):019:0* o={} => {} irb#1(main):020:0> h=Hash.new(o) => {} irb#1(main):021:0> h[:a][:b]=42 => 42 irb#1(main):022:0> h[:c]=42 => 42 irb#1(main):023:0> h => {:c=>42} irb#1(main):024:0> o => {:b=>42} or maybe even better h=Hash.new({}) => {} irb#1(main):027:0> h[:a][:b]=42 => 42 irb#1(main):028:0> h.default => {:b=>42} It is completely normal that h is empty you were working with it's default property HTH Robert -- We have not succeeded in answering all of our questions. In fact, in some ways, we are more confused than ever. But we feel we are confused on a higher level and about more important things. -Anonymous