Twig Components / Methods / reduce
Note: You are currently reading the documentation for Bolt 5.0. Looking for the documentation for Bolt 5.2 instead?
reduce(arrow, initial = null)
is a Twig filter to iteratively reduce a sequence or a mapping to a single value using
an arrow function, so as to reduce it to a single value. The arrow function receives the return value of the previous
iteration and the current value of the sequence or mapping.
The reduce filter takes an initial value as a second argument:
Note: the arrow function has access to the current context.
Arguments¶
arrow
: The arrow functioninitial
: The initial value
Source: Twig
Edit this page on GitHub
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.
Couldn't find what you were looking for? We are happy to help you in the forum, on Slack or on Github.