From: Daniel N Date: 2006-11-21T13:46:29+09:00 Subject: Re: array question ------=_Part_13885_29445802.1164084385353 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 11/21/06, Daniel N wrote: > > > > On 11/21/06, Wilson Bilkovich wrote: > > > > > > > > > > > A couple of ways: (there are probably dozens more) > > # given: > > array = [1,2,3,4,5,6] > > > > # 1. > > new_array = array[1..-2] > > > This would not duplicate the inner elements though. > > To build on this one. > b = a.inject( [] ) { |a,e| a << [e,e]}.flatten[1..-2] > > This looks pretty jarring to my eyes though :( > > > Sorry missed a brace on the block. Should be b = a.inject( [] ) { |a,e| a << [e,e]}.flatten[1..-2] } ------=_Part_13885_29445802.1164084385353--