Method: Array#first

Defined in:
array.c

#firstObject? #first(n) ⇒ Array

Returns the first element, or the first n elements, of the array. If the array is empty, the first form returns nil, and the second form returns an empty array.

a = [ "q", "r", "s", "t" ]
a.first    #=> "q"
a.first(1) #=> ["q"]
a.first(3) #=> ["q", "r", "s"]

Overloads:



740
741
742
# File 'array.c', line 740

static VALUE
rb_ary_first(argc, argv, ary)
int argc;