From: Kevin Smith Date: 2000-12-22T13:17:28+09:00 Subject: [ruby-talk:7940] Re: beginner's question -- hashes John Rubinubi wrote: >when I loop through the following... > >st=gets.chop! >if not hash[st] #I suppose I should use has_key? > hash[st]='some_value' >else > puts hash[st] >end > >when I go through the loop again and enter the same key it doesn't find it >although the same code finds the key-value pairs that I put in the hash >with a literal when I created it. I can't directly answer the question, but one of the first things I do when something happens that I don't understand is to start inspecting. Either before, or at the top of the loop, I would insert: p hash.inspect I would probably also p st just to make sure it contains what I think it does. Kevin