Todd Benson
7/19/2008 3:09:00 PM
On Wed, Jul 16, 2008 at 8:00 AM, Dave Bass <davebass@musician.org> wrote:
> Frederick Cheung wrote:
>> Seems like this was added in 1.8.7 (if you look at the docs for 1.8.6
>> you'll see it's not there)
>
> Workaround: in 1.8.6 use something like
>
> arr = n.times { arr.shift }
>
> to drop the first n entries from the array. Or Array.slice, which would
> probably be more efficient if you have to drop a large number of
> entries.
>
> Dave
Like David B. said. Also, if you left off the assignment, it would be
more like arr.drop! since it's destructive, which the docs don't
imply. I love shift and unshift for all kinds of things, but I would
go with indices (you could use slice, too).
I haven't played with 1.9 or 1.8.7, but I'm assuming that drop simply
returns arr[n..-1] without affecting the original array.
Todd