From: Ken Bloom Date: 2009-11-09T10:08:30+09:00 Subject: Re: A method that doesn't change its arguments On Sun, 08 Nov 2009 19:40:08 +0900, Timo Jeranko wrote: > At the moment I'm doing something like this: > > def some_method(array1) > ... > array2 = array1.clone > ... > array2.delete_at(i) > ... > return array2 > ... > end > > > I would like array1 to remain unchanged. It seems a little inefficient > to clone array1 every time some_method is called. Is there a more > elegant solution? If you're comfortable with the idea of using completely immutable lists, and not changing any of the elements of the list, an implementation of efficiently catenable lists (such as that described in "Purely Functional Data Structures") might be in order. -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/