From: Chris Dutton Date: 2001-12-30T13:17:54+09:00 Subject: [ruby-talk:29698] Re: Copying an Array in article a0lhmc$ljpsv$1@ID-42792.news.dfncis.de, Niko Schwarz at niko.schwarz@gmx.net wrote on 12/29/01 5:59 PM: > Matthew Diephouse wrote: > >> What's the best way to copy an array? > > Well, you could do this: > > copy = orig.clone > > if you have a 2d-array, try this: > > copy = orig.map { |el| el.clone } Well, I was only able to come up with a few different methods... original = ["foo", "bar"] newArray = original[0, original.length] original = ["foo", "bar"] newArray = original[0 .. original.length-1] original = ["foo", "bar"] newArray = [] + original