From: "Jesús Gabriel y Galán" Date: 2008-06-05T16:57:29+09:00 Subject: Re: double assignation in a hash On Thu, Jun 5, 2008 at 1:23 AM, nico Itkin wrote: > hi ! > > I'm new to ruby, i'd like to know if it is possible to make the > following kind of assignation in a hash, like i used to do in php : > > a={} > a[:b][:c]="value" > 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" Hope this helps, Jesus.