rails get last element of array code example Example: get last item in array ruby array = [1, 2, 3] array.last