enum.first â obj or nilenum.first(n) â an_array
Instance Public methods
Returns the first element, or the first n elements, of the
enumerable. If the enumerable is empty, the first form returns
nil, and the second form returns an empty array.
%w[foo bar baz].first #=> "foo"
%w[foo bar baz].first(2) #=> ["foo", "bar"]
%w[foo bar baz].first(10) #=> ["foo", "bar", "baz"]
[].first #=> nil