From: Robert Klemme Date: 2003-07-22T02:04:28+09:00 Subject: Re: Deep copy "Jason Creighton" schrieb im Newsbeitrag news:20030721103047.708f65ad.androflux@softhome.net.remove.to.reply... > On Mon, 21 Jul 2003 18:31:21 +0200 > "Simon Strandgaard" <0bz63fz3m1qt3001@sneakemail.com> wrote: > > > On Tue, 22 Jul 2003 01:43:45 +0900, Jim Freeze wrote: > > > > > Hi > > > > > > I find that when I need to do a deep copy that I > > > usually just do the following: > > > > > > x = Marshal.load(Marshal.dump(y) > > > > > > > > > Is there a more concise (possibly faster) method that > > > combines these two steps? If not, should we add one? > > > > How about this ? > > > > http://www.rubygarden.org/ruby?StandardClassExtensions/Object > > > > class Object > def deep_clone > Marshal::load(Marshal.dump(self)) > end > end Even more efficient: class Object def sheep_clone(); "Molly".dup; end end Ahem... robert