From: Tim Hunter Date: 2004-12-11T09:22:24+09:00 Subject: Re: How to make a deep copy of an object (Searching for Idiom) Brian Schr�der wrote: > Interesting. But this won't work for instance variables that point to > arrays of deep_copy-able objects. Right? I knew you'd spot that :-) In a couple of cases I had to replace Arrays with something like this: class Content < Array def deep_copy copy = self.class.new each do |c| copy << case when c.nil? nil when c.respond_to?(:deep_copy) c.deep_copy when c.respond_to?(:dup) c.dup else c end end return copy end end And, yes, I have to be careful not to use methods that return Array objects.