classdef MyClass < nelson.mixin.Copyable
b = copy(a)
| Parameter | Description |
|---|---|
| a | a handle object of a class deriving from nelson.mixin.Copyable. |
| Parameter | Description |
|---|---|
| b | an independent shallow copy of a. |
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.
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
| Version | Description |
|---|---|
| 2.0.0 | initial version |