On Sun, Nov 8, 2009 at 7:40 PM, Timo Jeranko <jeranko / gmail.com> wrote:
> At the moment I'm doing something like this:
>
> def some_method(array1)
> =A0...
> =A0array2 =3D array1.clone
> =A0...
> =A0array2.delete_at(i)
> =A0...
> =A0return array2
> =A0...
> end
>
>
> I would like array1 to remain unchanged. It seems a little inefficient
> to clone array1 every time some_method is called. =A0Is there a more
> elegant solution?
>

Couldn't you do something like this?

arr1 =3D ("a".."j").to_a
i =3D 3
p arr1[0...i]+arr1[i+1..-1]    #> ["a", "b", "c", "e", "f", "g", "h", "i", =
"j"]


Harry
--=20
A Look into Japanese Ruby List in English
http://www.kakueki.com/ruby/list.html