Method: Array#first
- Defined in:
- array.c
#first ⇒ Object? #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"]
740 741 742 |
# File 'array.c', line 740 static VALUE rb_ary_first(argc, argv, ary) int argc; |