Ruby/Hash/has value
Материал из Wiki.crossplatform.ru
Is it a value in the hash
hash = {} 1.upto(10) { |x| hash[x] = x * x } hash.has_value? 49 # => true hash.has_value? 81 # => true hash.has_value? 50 # => false
see if it has a given value with value? or has_value?:
zip = { 1 => "One", 2 => "Two", 3 => "Three", 4 => "Four", 5 => "Five", 6 => "Six", 7 => "Seven", 8 => "Eight", 9 => "Eight" } zip.has_value? "One" # => true