I find myself wanting something like Python's
ary = [1,2,3,4,5,6,7,8]
ary[2:] #=> [3,4,5,6,7,8]
ALL of the time these days.
The solution always ends up being multi-lined and ugly. I'm wondering what the most elegant solutions out there might be, because mine are not worth showing.
ary[2..-1].-1in a Range is somewhat ugly and magic when used in this context ( e.g.(2..-1).eachdoesn't match this behaviour).nitems, and can alterarr, you can usefront = arr.shift(n). A less-desirable alternative todrop(n)islast(arr.size-n).Array#[]is a.k.aArray#slice:ary[2..-1]can be writtenary.slice(2..-1).