Endless Range in Ruby 2.6
In Ruby 2.6 you don't need to specify -1
at the end of a range to get the rest of the elements:
> [1, 2, 3, 4][1..-1]
=> [2, 3, 4]
# with Ruby 2.6
> [1, 2, 3, 4][1..]
=> [2, 3, 4]
Tweet
In Ruby 2.6 you don't need to specify -1
at the end of a range to get the rest of the elements:
> [1, 2, 3, 4][1..-1]
=> [2, 3, 4]
# with Ruby 2.6
> [1, 2, 3, 4][1..]
=> [2, 3, 4]
Tweet