Mega Code Archive

 
Categories / Ruby / Hash
 

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