From: James Edward Gray II Date: 2007-06-26T11:11:56+09:00 Subject: Re: Some help needed with understanding ruby hashes On Jun 25, 2007, at 8:04 PM, Frank Church wrote: > > If a ruby hash rubyhash has a key such as "hashkey" is there a way of > retrieving the value by the expression rubyhash["hashkey"] ? > > It only seems logical that is rubyhash.has_key?("hashkey") returns > true > rubyhash["hashkey"] should return a value, but it always gives an > error. What you described is the standard Ruby behavior: $ irb >> hash = Hash.new => {} >> hash["some_key"] => nil >> hash["some_key"] = "I'm set now!" => "I'm set now!" >> hash.has_key? "some_key" => true >> hash["some_key"] => "I'm set now!" Note how I tried that out in the irb shell. It lets you enter Ruby expressions and examine their output. This is a powerful ally when learning the rules of Ruby. In short, something else is going on in your code. Hashes work as you expect. James Edward Gray II