Main Content


Determine number of values to return from customized indexing operations beginning with braces


n = braceListLength(obj,indexOp,indexContext)


n = braceListLength(obj,indexOp,indexContext) determines the number of values to return from customized indexing operations that begin with braces and that reference or assign to comma-separated lists. Operations that begin with brace indexing and end with dot or brace indexing produce comma-separated lists, such as [C{:}] = obj{1:3} and [obj{1}.prop{1:3}] = B{:}. The indices being changed and the types of indexing operations are described in indexOp, and indexContext identifies whether the reference is used in a statement, as a list of arguments to a function, or in an assignment operation.

Input Arguments

expand all

Object that implements customized brace indexing by inheriting from matlab.mixin.indexing.RedefinesBrace.

Types of indexing operations and indices referenced, specified as an array of IndexingOperation objects. For a brace reference, the first object in the array has a Type property of Brace.

Context in which the indexing operation occurs, specified as one of these enumeration members:

  • matlab.indexing.IndexingContext.Statement — Indexed reference used as a statement (for example, obj.a)

  • matlab.indexing.IndexingContext.Expression — Indexed reference used as an argument to a function (for example, func(obj.a))

  • matlab.indexing.IndexingContext.Assignment — Indexed assignment (for example, [obj.a] = deal(x)).

Output Arguments

expand all

Number of values to return from an indexing operation, specified as a nonnegative integer.



To learn about attributes of methods, see Method Attributes.


For an example of a class that implements custom brace indexing, see matlab.mixin.indexing.RedefinesBrace.

Introduced in R2021b