rassoc

hash.rassoc(obj) â an_array or nil
Instance Public methods

Searches through the hash comparing obj with the value using ==. Returns the first key-value pair (two-element array) that matches. See also Array#rassoc.

a = {1=> "one", 2 => "two", 3 => "three", "ii" => "two"}
a.rassoc("two")    #=> [2, "two"]
a.rassoc("four")   #=> nil
doc_ruby_on_rails
2015-04-12 00:22:23
Comments
Leave a Comment

Please login to continue.