nelson.mixin.Copyable
Add a copy method to a handle class.
📝Syntax
classdef MyClass < nelson.mixin.Copyable
b = copy(a)
📥Input Arguments
Parameter Description
a a handle object of a class deriving from nelson.mixin.Copyable.
📤Output Arguments
Parameter Description
b an independent shallow copy of a.
📄Description

Derive a handle class from nelson.mixin.Copyable to give it a copy method that returns an independent shallow copy of an object.

copy(a) creates a new object and copies each property value from a. Properties declared NonCopyable are not copied and keep their default value in the copy. The copy is shallow: handle-valued properties are shared between the original and the copy.

nelson.mixin.Copyable is itself a handle class.

💡Examples
A copyable handle class.
classdef Node < nelson.mixin.Copyable
  properties
    Value = 0
  end
end
a = Node();
a.Value = 42;
b = copy(a);
b.Value = 7;
a.Value   % still 42
🔗See Also
handleclassdef
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub