From: Simon Strandgaard Date: 2004-03-14T21:59:35+09:00 Subject: Re: Object#clone and Object#dup On Sat, 13 Mar 2004 14:44:54 +0100, Raphael Bauduin wrote: > I'd like to duplicate n object, work on the copy, and be sure the original > isn't change at all. How can I do that? [snip] Define your own #clone method, like this: server> ruby a.rb # # server> ruby a.rb # # server> expand -t2 a.rb class A def initialize(str) @str = str end attr_reader :str def change! @str << "changed!" end def clone A.new(@str.clone) end end a = A.new("hello") b = a.clone a.change! p a, b server> -- Simon Strandgaard