method

first

Importance_1
Ruby latest stable (v1_8_6_287) - 0 notes - Class: Array
first(...) public

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"]
Show source
Register or log in to add new notes.