/* * call-seq: * array.index(obj) -> int or nil * * Returns the index of the first object in <i>self</i> such that is * <code>==</code> to <i>obj</i>. Returns <code>nil</code> if * no match is found. * * a = [ "a", "b", "c" ] * a.index("b") #=> 1 * a.index("z") #=> nil */ static VALUE rb_ary_index(ary, val) VALUE ary; VALUE val; { long i; for (i=0; i<RARRAY(ary)->len; i++) { if (rb_equal(RARRAY(ary)->ptr[i], val)) return LONG2NUM(i); } return Qnil; }