From: Roger Braun Date: 2011-04-25T20:50:13+09:00 Subject: Re: problem with ruby19's Hash behavior Hi Aaron 2011/4/25 Aaron : > see the following codes pls, I wonder if this's a intent or a bug. For me the first line sounds better having same result with the later line > >>> [1].inject(Hash.new {[]}){ |result, i| result[:mem] << i;   result } > => {} >>> [1].inject(Hash.new {[]}){ |result, i| result[:mem] <<= i; result } > => {:mem=>[1]} It's the expected behaviour. See http://ruby-doc.org/core/classes/Hash.html#M000718. "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." [1].inject(Hash.new {|h,k| h[k] = Array.new}){ |result, i| result[:mem] << i; result } => {:mem=>[1]} -- Roger Braun rbraun.net | humoralpathologie.de