From: Dossy Date: 2002-09-20T23:55:21+09:00 Subject: Re: Checking hash key's and values, with case insensitivity On 2002.09.20, Khurram wrote: > How can I check hash keys and values without case sensitivity? > Specifically I'm referring to the hash ".has_key?" and ".has_value?" > methods. I believe these are case sensitive by default. class Hash def has_ikey?(key) self.keys.map { |key| key.upcase }.member? key.upcase end end hash = {"foo" => 1, "bar" => 2} hash.has_ikey? "foo" # => true hash.has_ikey? "FOO" # => true hash.has_ikey? "Foo" # => true hash.has_ikey? "quux" # => false -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)