Explain foreach's powers a bit more
This commit is contained in:
1 parent
ef9b591215
commit
6458910ba3
1 file changed
+4
-1
@@ -1842,7 +1842,10 @@ sections:
|
|||||||
for each new state to extract an output of `foreach`.
|
for each new state to extract an output of `foreach`.
|
||||||
|
|
||||||
This is mostly useful only for constructing `reduce`- and
|
This is mostly useful only for constructing `reduce`- and
|
||||||
`limit`-like functions.
|
`limit`-like functions. But it is much more general, as it
|
||||||
|
allows for partial reductions (see the example below), as well
|
||||||
|
as breaking out of the "loop" with `empty`, or even `error(x)`
|
||||||
|
if there's a try/catch around the foreach.
|
||||||
|
|
||||||
examples:
|
examples:
|
||||||
- program: '[foreach .[] as $item
|
- program: '[foreach .[] as $item
|
||||||
|
|||||||
Reference in new issue
Block a user