Indexing Operators
Learn to overload indexing operators for structs.
We'll cover the following...
Use of indexing operators
opIndex
, opIndexAssign
, opIndexUnary
, opIndexOpAssign
, and opDollar
make it possible to use indexing operators on user-defined types similar to arrays as in object[index]
.
Unlike arrays, these operators support multi-dimensional indexing as well. Multiple index values are specified as a comma-separated list inside the square brackets (e.g., object[index0, index1]
). In the following examples, we will use these operators only with a single dimension and cover their multidimensional uses in the more ...