Menu

Clonable

Nicolas Hainaux
There is a newer version of this page. You can find it here.

All core objects are Clonables.

This class provides them clone() which allows to create a deep copy of any object : obj.clone() will create a new object having the same content as the original. Using clone() allows to avoid bad surprises like loss of information when assigning or unwanted modifications happening after an assignation etc.

For instance, in __init__(), you'd better write :

self._field = arg.clone()

instead of :

self._field = arg

Note : clone() does not need to be reimplemented.

Back to Core Objects


Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.