List.reduce
reduce($callbackFunction, $initial = '') -> any
Description
Reduce the List to a single value, by applying a callback function to each item.
The callback receives 2 arguments:
carry
: the return value of the previous iterationitem
: the value of the current iteration
Returns the final, singular value.
$fnSum = fn ($total, $num) { return $total + $num } [3, 6, 9, 12].reduce($fnSum) //= 30