Method: Immutable::Vector#rassoc
- Defined in:
- lib/immutable/vector.rb
#rassoc(obj) ⇒ Object
Assumes all elements are nested, indexable collections, and searches through them, comparing obj with the second element of each nested collection. Return the first nested collection which matches, or nil if none is found. Behaviour is undefined when elements do not meet assumptions (i.e. are not indexable collections).
1273 1274 1275 1276 1277 1278 1279 |
# File 'lib/immutable/vector.rb', line 1273 def rassoc(obj) each do |array| next if !array.respond_to?(:[]) return array if obj == array[1] end nil end |