From: EdUarDo Date: 2005-09-17T00:26:35+09:00 Subject: Re: Hash table questions >> @position.post = :DC >> puts coords.has_key?(@position.post.to_s) >> puts coords.has_key?(@position.post) >> puts coords.has_key?('DC') >> >> Why I can't access 'DC' key with @position.post? > > > I suspect it's because the DC key had trailing whitespace, probably a > newline character. Try changing the reads to something like: > > pos = file.readline.strip > line = file.readline.strip > It works fine, thank you. Now I get a true answer when I ask: puts coords.has_key?(@position.post.to_s) puts coords.has_key?('DC') but not when puts coords.has_key?(@position.post) is this correct? Do I need to do .to_s to retrieve data from hash?