Range access

Syntax

expression[index]
or
expression[fromIndex...toIndex]

where:

Description

You can get an element at a specific position or a range of elements using this construct:

The fromIndex (inclusive) and toIndex (exclusive) numbers specifies the portion of the substring or sublist to retrieve.

Examples

// Gets the first character of a string (0-based indices)
myString[0]

// Gets a substring of 3 characters starting at index 1
myString[1..3]

// Gets the feature at index 1 of a UML class
myClass.feature[1]