From: "Jesús Gabriel y Galán" Date: 2011-12-06T01:44:16+09:00 Subject: Re: black magical hash element vivification On Mon, Dec 5, 2011 at 5:34 PM, Adam Prescott wrote: > On Mon, Dec 5, 2011 at 16:28, Chad Perrin wrote: > >>    >> foo = Hash.new( Hash.new ) >>    => {} >>    >> foo[3][2] = true >>    => true >>    >> foo >>    => {} >> > > This is odd. From the docs: http://ruby-doc.org/core-1.9.3/Hash.html#method-c-new Returns a new, empty hash. If this hash is subsequently accessed by a key that doesn’t correspond to a hash entry, the value returned depends on the style of new used to create the hash. In the first form, the access returns nil. If obj is specified, this single object will be used for all default values. If a block is specified, it will be called with the hash object and the key, and should return the default value. It is the block’s responsibility to store the value in the hash if required. The only thing that the second form does is return the same object for all missing keys. It doesn't store it in the hash. Jesus.