Array WIDTHOF Operator

The WIDTHOF operator returns the width of the array.

INT i;
INT[] array;    // default array size is zero
PRINT(WIDTHOF(array), "\n");
i := array[9];  // grows array to fit the index
PRINT(WIDTHOF(array), "\n");
array[19] := 42; // grows array to fit the index
PRINT(WIDTHOF(array), "\n");
0
10
20

For a Jagged Array (array of arrays), the WIDTHOF operator will return the number of arrays contained by the array. The widths of the sub-arrays can be obtained by querying them directly:

INT[][] i := { { 1, 2, 42 }, { 9, 72, 12, 4 } };

PRINT(WIDTHOF(i), "\n");
PRINT(WIDTHOF(i[1]), "\n");
2
4