instance method
second_to_last
Ruby on Rails 5.2.8.1
Since v5.2.8.1Signature
second_to_last()
Equal to self[-2].
%w( a b c d e ).second_to_last # => "d"
Source
# File activesupport/lib/active_support/core_ext/array/access.rb, line 89
def second_to_last
self[-2]
end
Defined in activesupport/lib/active_support/core_ext/array/access.rb line 89
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Array