From: Glen Holcomb Date: 2010-01-26T06:49:21+09:00 Subject: Re: Nested hash with arrays for default value --00032555b4ce0c9a41047e0424a3 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 2010/1/25 Jes=FAs Gabriel y Gal=E1n > On Mon, Jan 25, 2010 at 10:28 PM, Gary Wright wrote: > > > > On Jan 25, 2010, at 2:24 PM, Glen Holcomb wrote: > >> > >> I'll play around with your solution. I have the following: > >> > >> data =3D Hash.new { |l, k| l[k] =3D Hash.new { |l, k| l[k] =3D Hash.ne= w { |l, > k| > >> l[k] =3D Hash.new([]) }}} > > > > I'm assuming you want 'infinite' depth. Consider: > > > > default =3D lambda { |h,k| h[k] =3D Hash.new(&default) } > > top =3D Hash.new(&default) > > The problem is that he wants the leaves of the hash to be arrays, and > not hashes. > > Jesus. > > Exactly, infinite depth would be nice as it would make a more temporally portable solution. The proxy looks to be working great. I am a bit confused as to why the << method in the proxy doesn't overwrite a leaf with a new array though. I'm not complaining as it works the way I want it to, I'm just perplexed. Thanks Jesus. --=20 "Hey brother Christian with your high and mighty errand, Your actions speak so loud, I can=92t hear a word you=92re saying." -Greg Graffin (Bad Religion) --00032555b4ce0c9a41047e0424a3--