Method: Enumerable#take
- Defined in:
- enum.c
#take(n) ⇒ Array
Returns first n elements from enum.
a = [1, 2, 3, 4, 5, 0]
a.take(3) #=> [1, 2, 3]
|
# File 'enum.c'
static VALUE
enum_take(VALUE obj, VALUE n)
{
VALUE args[2];
long len = NUM2LONG(n);
if (len < 0) {
rb_raise(rb_eArgError, "attempt to take negative size");
}
|