> For the complete documentation index, see [llms.txt](https://trizen.gitbook.io/sidef-lang/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://trizen.gitbook.io/sidef-lang/programming_tasks/p/polymorphic_copy.md).

# Polymorphic copy

*Object.dclone()* makes a deep clone of any mutable object and returns it to the caller.

```ruby
class T(value) {
    method display {
        say value
    }
}

class S(value) < T {
    method display {
        say value
    }
}

var obj1 = T("T")
var obj2 = S("S")
var obj3 = obj2.dclone          # make a deep clone of obj2

obj1.value = "foo"              # change the value of obj1
obj2.value = "bar"              # change the value of obj2

obj1.display                    # prints "foo"
obj2.display                    # prints "bar"
obj3.display                    # prints "S"
```
