reference.language.slice.html Maven / Gradle / Ivy
Slice expressions
Slice expressions
Slice expressions are used to extract a sub-collection of a collection value.
A Slice expression is a code fragment which produces a value, whose type is determined by the value being retrieved,
which can then be used as an input for other operations: print, write, method call and so forth.
A Slice expression has the form collection[start:end]
where collection is a collection value and start and end are Integer values.
Either start or end can be omitted, but not both. If omitted, they are replaced by their default value
i.e. 1 and n where n is the number of collection items.
The end value can be negative, in which case Prompto will count backwards.
Both start and end items are included in the result.
If either start or end value is out of range, an INDEX_OUT_OF_RANGE error will be raised.
List slice
The type of the resulting value is the same as the List value.
Range slice
The type of the resulting value is the same as the Range value.
Text slice
Although Text values are considered 'atomic' by Prompto, it can be convenient to sometimes treat them as a List of Character.
The type of the resulting value is a Text.
© 2015 - 2025 Weber Informatics LLC | Privacy Policy