ary.assoc(obj) â new_ary or nil
Instance Public methods
Searches through an array whose elements are also arrays comparing
obj
with the first element of each contained array using
obj.==
.
Returns the first contained array that matches (that is, the first
associated array), or nil
if no match is found.
See also #rassoc
s1 = [ "colors", "red", "blue", "green" ] s2 = [ "letters", "a", "b", "c" ] s3 = "foo" a = [ s1, s2, s3 ] a.assoc("letters") #=> [ "letters", "a", "b", "c" ] a.assoc("foo") #=> nil
Please login to continue.