From: Joel VanderWerf Date: 2003-10-04T12:14:05+09:00 Subject: Re: hash of hashes Dave Brown wrote: > In article <200310031434.31907.argentoff@rtelekom.ru>, > Paul Argentoff wrote: > : On Friday 03 October 2003 14:04, Paul Argentoff wrote: > : > : > How can I create $Subject for future population? > : > : Let's put it this way: I need to create a nested hash which will be populated > : later by referencing the keys in the subhashes. How can I do this? > > You mean, er, > > irb(main):001:0> a=Hash.new({}) > => {} > irb(main):002:0> a['foo'] > => {} > > ? > > --Dave That's like, a real bad trip, dude: irb(main):002:0> a=Hash.new({}) => {} irb(main):003:0> a[1] => {} irb(main):004:0> a[1]["x"] = "y" => "y" irb(main):005:0> a => {} irb(main):006:0> a[1] => {"x"=>"y"} irb(main):007:0> a[1] = 2 => 2 irb(main):008:0> a[2] => {"x"=>"y"} irb(main):009:0> a[1] => 2 It would help to do a = Hash.new {{}} since you get a new hash each time...