From: Robert Klemme Date: 2012-09-19T06:08:31+09:00 Subject: Re: Bug or feature On Tue, Sep 18, 2012 at 8:44 PM, Damjan Rems wrote: > Robert Klemme wrote in post #1076432: > >> For full object tree copy you can do >> >> irb(main):007:0> c = Marshal.load(Marshal.dump(a)) > > Why is real cloning not implemented in ruby, since this fake cloning can > lead to a lot of troubles. What do you mean - "real cloning"? Shallow copy is as real as deep copy. They are just different concepts. If you think about it for a moment a deep copy is significantly more difficult to realize (especially with object graphs which have different paths to the same instance). It is totally reasonable to provide a shallow copy as default - btw. Java does it, too. And you can simply create your deep copy method: class Object def clone_deep Marshal.load(Marshal.dump(self)) end end Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/