From: Gareth Adams Date: 2006-11-25T18:40:14+09:00 Subject: Re: coding practise > sempsteen gmail.com> writes: Hi, I don't know too much about amicable numbers, but I can answer the first one... > 1-) What does "Hash#has_key?" actually do? > Why do we need such a method in spite of using the result of "Hash#[]" > method which will return nil for a non-present key. hsh = { :a => 5, :b => nil } hsh.has_key? :a # => true hsh[:a] # => 5 hsh.has_key? :b # => true hsh[:b] # => nil hsh.has_key? :c # => false hsh[:c] # => false Note that when the value of the hash item is nil or false, you'll get a difference between #as_key? and #[]