From: nobu.nokada@... Date: 2001-12-30T14:20:04+09:00 Subject: [ruby-talk:29705] Re: Copying an Array At Sun, 30 Dec 2001 07:57:28 +0900, Matthew Diephouse wrote: > What's the best way to copy an array? All I could could come up with is: > > arrayOne.each do |element| > arrayTwo.push(element) > end If arrayTwo exists already, to add all elements in arrayOne, arrayTwo.concat(arrayOne) To make a new copy of arrayOne, arrayTwo = arrayOne.dup or arrayTwo = [*arrayOne] Latter doesn't copy instance variables nor taintness. -- Nobu Nakada