...
Argument | Type | Description |
---|---|---|
$var | $-variable | A $-variable which will be set to each item in set in turn before script is processed. |
set | Array or Recordset | The set of items which will be iterated over. |
script | $-variable | A comma-separated list of expressions which will be processed once for each entry in set. |
forEach() is like every other function in that it returns a value.:
- Its return value is a list containing the last statement executed in each iteration.
- All the $-variables used in the call to forEach() keep their values between iterations.
- All the $-variables used in the call to forEach() will be available after it has returned.
...
Use in Conjunction With
Examples
In the first two examples, let
...
Returns 55. The forEach will return the value at each iteration ([1, 3, 6, 10, 15, 21, 28, 36, 45, 55]), the do then returns the final value of $sumOfNumbers.
Detailed example: (step-by-step)
Code Block |
---|
forEach( $customerType, customers.type, $total = $total + 1, if( $customerType == "Business", continue() ), $nonBusiness = $nonBusiness + 1, subString($customerType, 1, 6) ) |
...