From: Michael Artz Date: 2007-06-05T23:45:10+09:00 Subject: Deep Copy I'm needing to implement a deep copy operation on a couple of objects, and was wondering if there was a "best practices" for this sort of thing. I've seen the Marshal.load(Marshal.dump()) idiom, but I'm using singleton classes which can't be dumped. So I'm implementing my deep copy similar to: def deep_copy other = self.clone other.instance_var_1 = self.instance_var_1.clone other.instance_var_2 = self.instance_var_2.deep_copy other end where some of the instance variables are objects for which I've written a deep_copy method. The biggest problem with this method (that I can see), is that all of the attributes of the object need to be publically writable, which is undesirable. Is there a better way to do this sort of thing? Thanks, -Mike -- Posted via http://www.ruby-forum.com/.