From: Dave Bass Date: 2008-06-06T20:09:47+09:00 Subject: Re: double assignation in a hash Jes炭s Gabriel y Gal叩n wrote: > For arbitrary hash nesting, try this: > > irb(main):023:0> a = Hash.new {|h,k| h[k] = Hash.new(&h.default_proc)} > irb(main):024:0> a[1][2][3][4] = "hello" > irb(main):025:0> a > => {1=>{2=>{3=>{4=>"hello"}}}} > irb(main):026:0> a[1][2][3][4] > => "hello" Or this (longer but clearer IMO): a = {} a[1] = {} a[1][2] = {} a[1][2][3] = {} a[1][2][3][4] = "hello" print a[1][2][3][4] # "hello" -- Posted via http://www.ruby-forum.com/.