From: Li Chen Date: 2006-12-15T08:03:31+09:00 Subject: Re: Hash/2-d array help! Just Maz wrote: > Ah! Thanks. Got it totally working now! > > One other minor thing- would it be possible for the the strings inside > 'France' => ['Rennes', 'Paris'] > to be variables instead? > > i.e. instead of France= those two I earlier have a 'enter country name' > and 'enter city 1', 'enter city 2',etc... > > > Off the top of my head I think there may be some sort of symbol you'd > put before nation to show it is a actual stored string but I can't > remember what it was... Hi, Is the following what you try to do? Li ##script #:england and :france (or :England and :France) are symbols in ruby liverpool='Liverpool' london='London' plymouth='Pymouth' rennes='Rennes' paris='Paris' hash = { :england => [liverpool, london, plymouth], :france => [rennes, paris] } puts hash.fetch(:england)[0] puts hash.fetch(:england)[2] #output >ruby forum3.rb Liverpool Pymouth >Exit code: 0 -- Posted via http://www.ruby-forum.com/.