Shallow Copy: They don’t copy the objects that might be referenced within the copied object.In rails dup and clone are used for this.
Deep Copy: All the objects are copied.In rails deep_dup and deep_clone are used for this.
clone does two things that dup doesn’t:
1. Copy the singleton class of the copied object
2. Maintain the frozen status of the copied object
comments powered by