kernel/common/array.rb
# Assumes the Array contains other Arrays and searches through
# it comparing the given object with the first element of each
# contained Array using elem == obj. Returns the first contained
# Array that matches (the first 'associated' Array) or nil.
Assumes the Array contains other Arrays and searches through
it comparing the given object with the first element of each
contained Array using elem == obj. Returns the first contained
Array that matches (the first 'associated' Array) or nil.
Assumes the Array contains other Arrays and searches through it comparing the given object with the first element of each contained Array using elem == obj . Returns the first contained Array that matches ( the first ' associated ' Array ) or nil .
def assoc(obj)
    i = 0
    while(i < @total)
      elem = at(i)
      if elem.kind_of? Array and elem.first == obj
        return elem
      end
      i += 1
    end
    nil
  end
def assoc ( obj ) i = 0 while ( i < @total ) elem = at ( i ) if elem . kind_of? Array and elem . first == obj return elem end i += 1 end nil end
Assumes the Array contains other Arrays and searches through
it comparing the given object with the first element of each
contained Array using elem == obj.
Assumes the Array contains other Arrays and searches through it comparing the given object with the first element of each contained Array using elem == obj .
obj
<not_specific>