Repetition
Use the for
-in
syntax to create an element multiple times.
The syntax looks like this: for name[index] in model : id := Element { ... }
The model can be of the following type:
- an integer, in which case the element will be repeated that amount of time
- an array type or a model declared natively, in which case the element will be instantiated for each element in the array or model.
The name will be available for lookup within the element and is going to be like a pseudo-property set to the value of the model. The index is optional and will be set to the index of this element in the model. The id is also optional.
Examples
Arrays and Models
Arrays are declared by wrapping [
and ]
square brackets around the type of the array elements.
Array literals as well as properties holding arrays act as models in for
expressions.
Arrays define the following operations:
array.length
: One can query the length of an array and model using the builtin.length
property.array[index]
: The index operator retrieves individual elements of an array.
Out of bound access into an array will return default-constructed values.
© 2024 SixtyFPS GmbH