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. <florent2 / gmail.com> 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.