From: aero6dof@... (Alan Chen) Date: 2003-09-03T06:33:31+09:00 Subject: Re: show me the ruby way ts wrote in message news:<200309021525.h82FPkM17085@moulon.inra.fr>... > try this (only with ruby-1.8) > > metaData = Hash.new {|h, k| h[k] = Hash.new(0) } > > when ruby try to access a key which is not defined, it call the block with > (hash, key), you store in hash[key] a new hash with `0' as default value On a related note, with ruby 1.8.0 (2003-08-04) [i386-mswin32], I was wondering about this behavior: md = Hash.new { |h,k| h[h] = 0; 3 } p md[1] # => 3 p md[1] # => 0 I understand that the first "p md[1]" is returning the result of the block; is that intentional? Cheers, alan