From: Kent Dahl Date: 2002-12-17T17:25:00+09:00 Subject: Re: Deep copy in Rub? Matt Armstrong wrote: > In addition to the other answers, there are two methods to copy an > object in Ruby. Object.dup and Object.clone. > > I'm not sure why -- they don't do anything different in the standard > classes. The Pickaxe book says they might do something different in > derived classes, but stops short of suggesting a practice (e.g. clone > does deep copy and dup does shallow copy). There are differences: [kentda@v052a kentda]$ irb irb(main):001:0> a = "Hi" "Hi" irb(main):002:0> a.freeze "Hi" irb(main):003:0> a.dup.frozen? false irb(main):004:0> a.clone.frozen? true -- (\[ Kent Dahl ]/)_ _~_ __[ http://www.stud.ntnu.no/~kentda/ ]___/~ ))\_student_/(( \__d L b__/ NTNU - graduate engineering - 5. year ) ( \__\_�|�_/__/ ) _)Industrial economics and technological management( \____/_�_\____/ (____engineering.discipline_=_Computer::Technology___)