On Nov 4, 9:48 ¨Âí¬ Áìäòéã Çéáãïíïî¼áìä®®®Àôòåöïëå®îåô¾ ÷òïôåº > irb(main):086:0> a = Hash.new(Hash.new) > => {} > irb(main):087:0> a[5] > => {} > irb(main):088:0> a[5][4] = 3 > => 3 > irb(main):089:0> a > => {} > irb(main):090:0> a[5] > => {4=>3} > irb(main):091:0> a[5][4] > => 3 > irb(main):092:0> RUBY_DESCRIPTION > => "ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-mswin32]" > > Upon inspection of 'a', it sure seems that it's empty, but upon > inspection of the key, it does have a value attached to it! Can we trust > this? Expected / unexpected behavior ? Maybe this might explain the behavior a bit more clearly: >> d = Hash.new => {} >> a = Hash.new(d) => {} >> a[5][4] = 3 => 3 >> a => {} >> a[5] => {4=>3} >> a[6] => {4=>3} >> d => {4=>3} Notice that the default value for hash a (the other hash) has changed. And you've already noticed that the hash just appears to have values when queried specifically, but not when inspected. You probably want to declare the hash as Hash.new { |h, k| h[k] = {} } -- -yossef