Check out example codes for "how to find last elemnet in ruby array". It will help you in understanding the concepts better.

Code Example 1

a[-1] # => 5
b[-1] # => 6

Learn ReactJs, React Native from akashmittal.com