From: chen li Date: 2006-12-15T04:08:05+09:00 Subject: Re: Hash/2-d array help! > Ah....now that's a lot simpler then I thought. > How would I then retrieve these values? > > puts hash gives error as does puts hash[England] or > puts > hash{England}...Are they counted in anyway like > hash{england[1]}? Hi, This is right syntax to create a hash(with single or double quotes), actually you declare a hash of arrays(HOA): hash = { 'England' => ['Liverpool', 'London', 'Plymouth'], 'France' => ['Rennes', 'Paris'] } If you just write England=>[Liverpool, London, Plymouth] Ruby thinks every of them is a constant due to capitalization. hash.fetch('England') will return an array then you index the array to get the element you want. Li C:\>irb irb(main):001:0> hash = { irb(main):002:1* 'England' => ['Liverpool', 'London', 'Plymouth'], irb(main):003:1* 'France' => ['Rennes', 'Paris'] irb(main):004:1> } => {"France"=>["Rennes", "Paris"], "England"=>["Liverpool", "London", "Plymouth"]} irb(main):005:0> hash.fetch('England')[0] => "Liverpool" irb(main):006:0> hash.fetch('England')[2] => "Plymouth" irb(main):007:0> ____________________________________________________________________________________ Do you Yahoo!? Everyone is raving about the all-new Yahoo! Mail beta. http://new.mail.yahoo.com