From: Li Chen Date: 2006-11-21T14:13:14+09:00 Subject: Re: array question > 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 -- Posted via http://www.ruby-forum.com/.