Skip to main content
Skip table of contents

Get Array Element Operator [ ]

Syntax
NONE
anArray[anIndex]
SemanticsThe operator [i] returns the i-th element of the array. The first element has the position 0. anIndex can be a static integer literal, an object of type Integer, or an E2E Action Language operation or expression returning an integer.
SubstitutablesanArrayCan be any variable or object attribute having the type Array
anIndexCan be any expression that evaluates to an integer.

It is not possible to use class operations as index function – only built-in E2E Action Language operations are allowed.

Examples
NONE
set arrayElement = inputContainer.myList[0];
set arrayElement = anArray[anArray.count() - 1].mySubList;
set arrayElement = anArray[indexVariable];

Example File (Builder project E2E Action Language/Array):

<your example path>\E2E Action Language\Array\uml\arrayGetElement.xml

Consider the example being displayed below. InputContainer is an object that contains an array of type String. This array is named myList and can have zero to n elements. You can select a specific element of an array by using its index. The indices start at 0. To get a reference of the first myList item, the following statement is used:

CODE
set arrayElement1 = inputContainer.myList[0];

In an activity diagram, this looks like shown below.

Figure: Using the[ ]-Operator: A Simple Example

The index number can be a static integer literal, an object of type Integer or an E2E Action Language operation or expression returning an integer. The following activity diagram illustrates some of the more complicated cases:

Figure: Using the[ ]-Operator: A Complex Example

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.