first

ary.first â obj or nil
ary.first(n) â new_ary
Instance Public methods

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. See also #last for the opposite effect.

a = [ "q", "r", "s", "t" ]
a.first     #=> "q"
a.first(2)  #=> ["q", "r"]
doc_ruby_on_rails
2015-03-30 17:12:48
Comments
Leave a Comment

Please login to continue.