classdef MyClass < nelson.mixin.indexing.RedefinesBrace
| Parameter | Description |
|---|---|
| obj | an object of a class deriving from nelson.mixin.indexing.RedefinesBrace. |
| Parameter | Description |
|---|---|
| obj | an object supporting customized brace indexing. |
Derive from nelson.mixin.indexing.RedefinesBrace to give a class its own brace indexing behavior. A subclass implements the protected methods braceReference(obj, indexOp) (value of obj{...}), braceAssign(obj, indexOp, value) (obj{...} = value) and braceListLength(obj, indexOp, indexContext).
indexOp is a nelson.indexing.IndexingOperation whose Indices property is a cell array of the subscripts.
classdef Bag < nelson.mixin.indexing.RedefinesBrace
properties
Data
end
methods
function obj = Bag(x)
obj.Data = x;
end
end
methods (Access = protected)
function varargout = braceReference(obj, indexOp)
varargout{1} = obj.Data{indexOp.Indices{1}};
end
function obj = braceAssign(obj, indexOp, val)
obj.Data{indexOp.Indices{1}} = val;
end
function n = braceListLength(obj, indexOp, ctx)
n = 1;
end
end
end
| Version | Description |
|---|---|
| 2.0.0 | initial version |