SyntaxFix
Write A Post
Hire A Developer
Questions
Use -1 index (negative indices count backward from the end of the array):
-1
a[-1] # => 5 b[-1] # => 6
or Array#last method:
Array#last
a.last # => 5 b.last # => 6