From: Wilson Bilkovich Date: 2006-11-21T14:18:27+09:00 Subject: Re: array question On 11/21/06, Li Chen wrote: > > > A couple of ways: (there are probably dozens more) > > # given: > > array = [1,2,3,4,5,6] > > > > # 1. > > new_array = array[1..-2] > > > > # 2. > > new_array = array.dup > > new_array.shift # shifts off the first element > > new_array.pop # pops off the last element > > > > #1 uses Array#[], which is a synonym for Array#slice. > > 1..-2 is a Range parameter. In this case, it says you want a slice of > > the array containing everything but the first and last element. > > > Hi, > > I run array=[1,2,3,4,5] > new_array = array.dup > new_array.shift > new_array.pop > I get [2,3,4] but I want this result [1,2,2,3,3,4,4,5] > > Li Yeah. Sorry. I didn't read your question clearly enough. I apologize for confusing the issue. Check out the other replies from people with better reading comprehension late at night. Heh.