nelson.mixin.Heterogeneous
Allow arrays that mix related classes.
📝Syntax
classdef MyBase < nelson.mixin.Heterogeneous
📥Input Arguments
Parameter Description
obj an object of a class deriving from nelson.mixin.Heterogeneous.
📤Output Arguments
Parameter Description
obj an object that can participate in a heterogeneous array.
📄Description

Derive a class from nelson.mixin.Heterogeneous to allow arrays that contain a mix of objects of that class and of its subclasses. Such an array takes the class of the nearest common nelson.mixin.Heterogeneous ancestor of its elements.

Without this mixin, concatenating objects of different classes is an error. With it, related classes sharing a heterogeneous root can be stored together in one array.

💡Examples
A heterogeneous shape hierarchy.
classdef Shape < nelson.mixin.Heterogeneous
end
% classdef Circle < Shape ... end
% classdef Square < Shape ... end
% shapes = [Circle(), Square()];   % a Shape array
🔗See Also
classdef
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub