Paul Argentoff wrote: >On Friday 03 October 2003 14:48, Emmanuel Touzery wrote: > > > >>irb(main):001:0> a = {} >>{} >>irb(main):002:0> a["blue"] = {} >>{} >>irb(main):003:0> a["blue"]["red"] = 3 >>3 >>irb(main):004:0> a["blue"] >>{"red"=>3} >>irb(main):005:0> a["blue"]["red"] >>3 >>irb(main):006:0> >> >> > >I need something like this: > >a = {{}} # this doesn't work, but i've just written it here to emph. the > # subject >... ># somewhere in the iteration >a[foo][bar] = baz >... > > i think you need ruby 1.8's block form for creating hashes. i asked that question recently, and here is the snippet from Guy Decoux: svg% ruby -e 'has = Hash.new {|h,k| h[k]={}}; has["blue"]["red"] = 1; p has' {"blue"=>{"red"=>1}} svg%