From: Harry Kakueki Date: 2009-04-27T13:41:01+09:00 Subject: Re: How to parse a "line"? On Mon, Apr 27, 2009 at 1:07 PM, Todd Benson wrote: > On Sun, Apr 26, 2009 at 11:03 PM, Todd Benson wrote: >> On Sun, Apr 26, 2009 at 10:59 PM, 7stud -- wrote: >>> Todd Benson wrote: >>>> My way was only slightly different. I opted to create the whole >>>> array, and then drop the first without creating an extra object. >>> >>> Note that you made ruby go through the laborious chore of shifting every >>> element in the array over one spot to the left. >> >> Is that really what happens? I thought it just reassigned a starting >> point, and indexed from there. At least, that would make more sense >> to me if it did. > > Let me rephrase. What is different on the underlying structure with > [1..-1] and #shift? I'm not sure if shift really moves everything, > but if it does, I wouldn't mind knowing. > > Todd > > If it shifts everything, it sure does it fast :) p Time.now arr = (1..100_000_000).to_a p Time.now arr.shift p arr[0] p Time.now ###output Mon Apr 27 13:34:06 +0900 2009 Mon Apr 27 13:36:29 +0900 2009 2 Mon Apr 27 13:36:29 +0900 2009 Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html