This post originated from an RSS feed registered with Ruby Buzz
by Bob Hutchison.
Original Post: Ruby's Array>>shift is shifty
Feed Title: This used to be fun! ... What happened? | Ruby
Feed URL: https://bobhutchison.wordpress.com/feed/
Feed Description: The Ruby side of my efforts to put the fun back into programming.
Here is a simple Ruby expression:
(a = [1, 2, 3]).shift
The value of a will be [2, 3] which is exactly what you'd expect. The thing is, there is a bug here.
The Pick Axe book describes the shift function as:
Returns the first element of arr and removes it (shifting all other ...