From: Phrogz Date: 2009-11-08T23:25:06+09:00 Subject: Re: A method that doesn't change its arguments On Nov 8, 3:38 am, 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? Could you clarify what you're trying to do? What you've shown is a method that takes an array and then returns a slightly modified version. If you don't want the original to be modified, what's your other option? Are you aware that array duplication is a 'shallow' operation? All you're doing is (efficiently) copying a list of references to objects, not the objects themselves. As lith ≈wrote, avoid premature optimization. You may be spending your time and ours on a complete non- issue.