From: "ToMaTo@..." Date: 2011-11-18T02:55:10+09:00 Subject: Re: Problem on hash with default value --0015174c42ceb14a2404b1f1eba9 Content-Type: text/plain; charset=ISO-8859-1 Go ahead and check the doc: http://www.ruby-doc.org/core-1.9.3/Hash.html#method-c-new On Thu, Nov 17, 2011 at 12:45 PM, Florent G. wrote: > Hi, > > I face the following issue with a hash having an empty array as default > value. > > I don't how to describe it in English, here is an illustrative code: > > hash = Hash.new Array.new > > hash[:a] = [1] > > hash[:b] << 2 > > puts hash[:b] > # => returns [2] > > puts hash.keys > # => returns [:a], not [:a, :b] ? > > hash[:b] is set to [2] but I don't understand why hash.keys does not > include :b. > > Thanks!, > Florent > > -- > Posted via http://www.ruby-forum.com/. > > -- Life is a miracle. --0015174c42ceb14a2404b1f1eba9--