From: Alex Date: 2009-06-19T03:45:22+09:00 Subject: Re: Modifying data in an array using a reference --001485f8955e3b4346046ca3cf30 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Just find the index of the object. For instance, if you're iterating the array with .each like: arr.each do |e| modified = modify(e) end You could do something like this: arr.each_with_index do |e, i| arr[i] = modify(e) end Alex On Thu, Jun 18, 2009 at 2:38 PM, Ch Ba wrote: > Ok so my situation is as follows. I have an array "foo", which contains > several instances of the class "bar". I get a copy of an object inside > of "foo" using foo.detect, and then modify that copy. Afterwards, I > need to replace the original inside the array with the modified version. > The problem is that I do not know the index of the object. How would I > go about doing that? I could use some help =) > -- > Posted via http://www.ruby-forum.com/. > > --001485f8955e3b4346046ca3cf30--