From: Gabe Da silveira Date: 2009-04-03T01:24:57+09:00 Subject: Re: how to make a[2][3]=4 wrk? (auto-initialize nested hash) Daniel Martin wrote: > In addition to what's already been posted, there's this, which doesn't > require any extra variables or methods: > > a = Hash.new{|h,k| h[k]=Hash.new &h.default_proc} That's clever, but I think the way it automatically creates keys is wrong. You need to be able to check to see if a key exists without polluting the hash with a bunch of empties. Hence my new gem: http://github.com/dasil003/safe-nested-hash -- Posted via http://www.ruby-forum.com/.