take(p1)
public
Returns first n elements from ary.
a = [1, 2, 3, 4, 5, 0]
a.take(3)
Show source
static VALUE
rb_ary_take(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);
}