TL;DR:
- clone duplicates most of the things (including singleton methods, freeze state, etc.)
- dup creates “shallow copy”
Let’s create simple Person class and one person object with singleton method.
Let’s se what happens if we try to access singleton person method with dup or clone.
We just found the first difference between dup and clone. Let’s also freeze the person before duplicating the object and see what happens.
The best thing to remember the difference betwen dup and clone is that dup is a “shallow” copy and clone make almost exact copy of the object.