From: chr_rippel@... (Christoph) Date: 2002-03-28T07:39:50+09:00 Subject: RE: Hash.new(Hash.new) doesn't use Hash.new as default value > From: Yukihiro Matsumoto ... > |Rather than have the block simply return a default value, give it > |enough context to let it assign that value or not: > | > | h = Hash.new { 0 } # simply return 0, do not alter the hash > | > | h = Hash.new { |hash, key| hash[key] = Hash.new } # put a new hash > | # in place > | > |That gives control back to the developer. > > Fortunately, it already works exactly you described. I thought that the ``hash'' argument was pretty much superfluous - guess I was wrong. Here is a working n-dimensional solution cvs-solution which is strictly relying on the apparent useless hash parameter ---- default = nil default = proc do |hash, key| hash[key] = Hash.new default end var = Hash.new (&default) ---- /Christopc