From: Dave Thomas Date: 2002-03-28T03:00:02+09:00 Subject: Re: Hash.new(Hash.new) doesn't use Hash.new as default value matz@ruby-lang.org (Yukihiro Matsumoto) writes: > |Perhaps the distinction is whether it's being used as an lvalue or an > |rvalue. As an lvalue, it should be stored, but as an rvalue it > |probably shouldn't. > > Sounds interesting. Unfortunately, there's no way to distinguish > lvalue and rvalue. OK - plan B 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. Dave