foreach
Repeats content for each element of an iterable collection. The current element can be accessed via the lambda argument, which may be either explicit or implicit.
.var {collection}
- A
- B
- C
.foreach {.collection}
element:
The current element is **.element**
Content copied to clipboard
In implicit form:
.foreach {.collection}
The current element is **.1**
Content copied to clipboard
In case the iterable is destructurable (e.g. a dictionary) and the lambda body has more than 1 explicit parameter, the value is destructured into components.
.var {x}
.dictionary
- a: 1
- b: 2
- c: 3
.foreach {.x}
key value:
**.key** has value **.value**
Content copied to clipboard
Return
a collection that contains the output of each iteration
Parameters
iterable
collection to iterate
body
content, output of each iteration. Accepts 1 parameter (the current element).