ruby find last occurrence in array code example Example: how to find last elemnet in ruby array a[-1] # => 5 b[-1] # => 6