= private = protected
has_value?(p1)
Returns true if the given value is present for some key in hsh.
h = { "a" => 100, "b" => 200 } h.value?(100) #=> true h.value?(999) #=> false
static VALUE rb_hash_has_value(VALUE hash, VALUE val) { VALUE data[2]; data[0] = Qfalse; data[1] = val; rb_hash_foreach(hash, rb_hash_search_value, (VALUE)data); return data[0]; }
Remember that checking for a value is a potentially slow operation (all the elements might be iterated) as oposed to querying a key (e.g. with has_key?), which is supposed to be fast in a Hash.