From: Rodrigo Bermejo Date: 2008-06-06T04:17:20+09:00 Subject: Re: Accessing a hash in a hash Justin To wrote: > > Hello, I'm new to Ruby and am trying this example problem. I'm suppose > to have a hash key whose value is a hash. > Ex. hash['a'] => hash > > Then, I'm suppose to change the second hash's keys and values... > > how do i go about this? > > Hash1: Key => ( Hash2: aKey => aValue ) > > I want to change aKey and aValue > > Hash1[key]?????? > > How do I index it, or access it?? > > Thanks in advance!!!! ---> a["b"]["c"]=2 D:>irb irb(main):001:0> a={} => {} irb(main):002:0> a["b"]={"c" => "1"} => {"c"=>"1"} irb(main):004:0> require 'pp' => true irb(main):005:0> pp a {"b"=>{"c"=>1}} => nil irb(main):006:0> a["b"]["c"]=2 => 2 irb(main):007:0> pp a {"b"=>{"c"=>2}} => nil -- Posted via http://www.ruby-forum.com/.