ruby array pick last one code example
Example 1: array ruby taking 3 last value
@numbers = [ 1, 2, 3, 4, 5, 6, 7, 8 ]
@numbers.last(2) # => [7,8]
Example 2: how to find last elemnet in ruby array
a[-1] # => 5
b[-1] # => 6
@numbers = [ 1, 2, 3, 4, 5, 6, 7, 8 ]
@numbers.last(2) # => [7,8]
a[-1] # => 5
b[-1] # => 6