Project

General

Profile

Bug #9855

nested hash with clone method , it act as a reference but object id are different

Added by neerajdoharey (Neeraj Doharey) about 6 years ago. Updated about 6 years ago.

Status:
Rejected
Priority:
Normal
Assignee:
-
Target version:
ruby -v:
2.1.0 , 1.9.3
[ruby-core:62681]

Description

there is a problem with nested hash ,
when i clone a nested hash it act as a reference an when i remove an element from the cloned newly created hash , the previous hash is same as newly create hash.
there object id are different
i am sending the screenshot of the problem that i face


Files

Screen Shot 2014-05-19 at 10.54.18 pm.png (431 KB) Screen Shot 2014-05-19 at 10.54.18 pm.png neerajdoharey (Neeraj Doharey), 05/19/2014 05:35 PM

Updated by marcandre (Marc-Andre Lafortune) about 6 years ago

  • Status changed from Open to Rejected
  • Assignee deleted (ephoenix (Evan Phoenix))

This is expected behavior. clone is only a shallow clone and thus the values of a hash are not cloned themselves.

Also available in: Atom PDF