Sebastian Hungerecker
10/3/2007 10:16:00 AM
Jakub Kuzma wrote:
> Hello,
>
> Could somebody explain me the following behavior?
>
> irb(main):001:0> h = Hash.new([])
> => {}
> irb(main):002:0> h[1].push(1)
> => [1]
> irb(main):003:0> h
> => {}
Hash.new(arg) makes arg the default, but it doesn't assign to the hash. You
want h = Hash.new {|h,k| h[k] = []}
HTH,
Sebastian
--
Jabber: sepp2k@jabber.org
ICQ: 205544826