nelson.mixin.indexing.RedefinesDot
Customize dot indexing of a class.
📝Syntax
classdef MyClass < nelson.mixin.indexing.RedefinesDot
📥Input Arguments
Parameter Description
obj an object of a class deriving from nelson.mixin.indexing.RedefinesDot.
📤Output Arguments
Parameter Description
obj an object supporting customized dot indexing.
📄Description

Derive from nelson.mixin.indexing.RedefinesDot to give a class its own dot indexing behavior for names that are not declared properties or methods. A subclass implements the protected methods dotReference(obj, indexOp) (value of obj.name), dotAssign(obj, indexOp, value) (obj.name = value) and dotListLength(obj, indexOp, indexContext).

indexOp is a nelson.indexing.IndexingOperation whose Name property holds the accessed name. Declared properties and methods keep their normal behavior; only unknown names call dotReference/dotAssign.

💡Examples
A dynamic name/value bag.
classdef Bag < nelson.mixin.indexing.RedefinesDot
  properties (Access = private)
    Store
  end
  methods
    function obj = Bag()
      obj.Store = struct();
    end
  end
  methods (Access = protected)
    function varargout = dotReference(obj, indexOp)
      varargout{1} = obj.Store.(indexOp.Name);
    end
    function obj = dotAssign(obj, indexOp, val)
      obj.Store.(indexOp.Name) = val;
    end
    function n = dotListLength(obj, indexOp, ctx)
      n = 1;
    end
  end
end
🔗See Also
nelson.mixin.indexing.RedefinesParennelson.indexing.IndexingOperation
🕔Version History
Version Description
2.0.0 initial version
Edit this page on GitHub