How to check if specific value is present in a hash?

Hash includes Enumerable, so you can use the many methods on that module to traverse the hash. It also has this handy method:

hash.has_value?(value_you_seek)

To find the key associated with that value:

hash.key(value_you_seek)

This API documentation for Ruby (1.9.2) should be helpful.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)