take(p1)
public
Returns first n elements from ary.
a = [1, 2, 3, 4, 5, 0]
a.take(3)
Show source
/*
* call-seq:
* ary.take(n) => array
*
* Returns first n elements from <i>ary</i>.
*
* a = [1, 2, 3, 4, 5, 0]
* a.take(3)
*
*/
static VALUE
rb_ary_take(obj, n)
VALUE obj;
VALUE n;
{
long len = NUM2LONG(n);
if (len < 0) {
rb_raise(rb_eArgError, "attempt to take negative size");
}
return rb_ary_subseq(obj, 0, len);
}