From: Jim Cochrane Date: 2006-11-26T06:15:07+09:00 Subject: Re: coding practise On 2006-11-25, Vidar Hokstad wrote: > > sempsteen wrote: >> 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. > > Because you won't know if a "nil" result from Hash#[] means that you > tried to access a non-existing key or if you accessed a key where the > _value_ is nil. > It also allows for good code readability - 'has_key?': It's pretty obvious to, e.g., a reviewer what the code wants to do. --