Using Subscripts in Arrays

The bracket ([]) subscript operators enable you to assign values to and read values from an array. The code fragments in the following examples show the syntax of bracket subscript operators in Array methods.

stringArray[5] := "Five";
str := stringArray[5];

The index value for an array must be of type Integer. The other numeric types are not allowed in this context.

However, for large arrays it is more efficient to use an iterator to traverse an array than it is to index your way through. For example, the code shown in the first of the following code fragments is preferable to that shown in the second code fragment.

foreach str in array do
    string := str;
endforeach;
while number <= array.size do
    string := array[number];
    number := number + 1;
endwhile;