From: Harry Kakueki Date: 2009-11-08T21:19:43+09:00 Subject: Re: A method that doesn't change its arguments On Sun, Nov 8, 2009 at 7:40 PM, 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? > Couldn't you do something like this? arr1 = ("a".."j").to_a i = 3 p arr1[0...i]+arr1[i+1..-1] #> ["a", "b", "c", "e", "f", "g", "h", "i", "j"] Harry -- A Look into Japanese Ruby List in English http://www.kakueki.com/ruby/list.html