arr[-1]
gives you the last element of arr
, arr[-2]
the second-to-last element and so on.
arr[2, 3]
gives you from the element at index 2, three elements of arr
arr[2..3]
gives you from the element at index 2 to the element at index 3
2
solved Accessing ruby elements