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