rassoc

ary.rassoc(obj) â new_ary or nil
Instance Public methods

Searches through the array whose elements are also arrays.

Compares obj with the second element of each contained array using obj.==.

Returns the first contained array that matches obj.

See also #assoc.

a = [ [ 1, "one"], [2, "two"], [3, "three"], ["ii", "two"] ]
a.rassoc("two")    #=> [2, "two"]
a.rassoc("four")   #=> nil
doc_ruby_on_rails
2015-03-30 18:53:44
Comments
Leave a Comment

Please login to continue.