public Method

Array.include?(p1)

array.include?(obj)    true or false

Returns true if the given object is present in self (that is, if any object == anObject), false otherwise.

a = [ "a", "b", "c" ]
a.include?("b")   #=> true
a.include?("z")   #=> false

Source Code

/*
*  call-seq:
*     array.include?(obj)   -> true or false
*  
*  Returns <code>true</code> if the given object is present in
*  <i>self</i> (that is, if any object <code>==</code> <i>anObject</i>),
*  <code>false</code> otherwise.
*     
*     a = [ "a", "b", "c" ]
*     a.include?("b")   #=> true
*     a.include?("z")   #=> false
*/

VALUE
rb_ary_includes(ary, item)
   VALUE ary;
   VALUE item;
{
   long i;

   for (i=0; i<RARRAY(ary)->len; i++) {
       if (rb_equal(RARRAY(ary)->ptr[i], item)) {
           return Qtrue;
       }
   }
   return Qfalse;
}
Comments

Have your say
Please use Textile formatting (click here for a cheat sheet). Use <code/> and <pre/> for code samples.
Click here to login with OpenID to to post comments.