public Method

Array.delete_at(p1)

array.delete_at(index)   obj or nil

Deletes the element at the specified index, returning that element, or nil if the index is out of range. See also Array#slice!.

a = %w( ant bat cat dog )
a.delete_at(2)    #=> "cat"
a                 #=> ["ant", "bat", "dog"]
a.delete_at(99)   #=> nil

Source Code

/*
*  call-seq:
*     array.delete_at(index)  -> obj or nil
*  
*  Deletes the element at the specified index, returning that element,
*  or <code>nil</code> if the index is out of range. See also
*  <code>Array#slice!</code>.
*     
*     a = %w( ant bat cat dog )
*     a.delete_at(2)    #=> "cat"
*     a                 #=> ["ant", "bat", "dog"]
*     a.delete_at(99)   #=> nil
*/

static VALUE
rb_ary_delete_at_m(ary, pos)
   VALUE ary, pos;
{
   return rb_ary_delete_at(ary, NUM2LONG(pos));
}
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.