yield
Operator
yield — emit values from expressions
Synopsis
[yield] <expr> [, <expr>...]
Description
The yield
operator produces output values by evaluating one or more
expressions on each input value and sending each result to the output
in left-to-right order. Each <expr>
may be any valid
expression.
The yield
keyword is optional since it is an
implied operator.
Examples
Hello, world
yield "hello, world"
null
Loading...
echo 'null' \
| super -z -c 'yield "hello, world"' -
Yield evaluates each expression for every input value
yield 1,2
null
null
null
Loading...
echo 'null
null
null' \
| super -z -c 'yield 1,2' -
Yield typically operates on its input
yield this*2+1
1
2
3
Loading...
echo '1
2
3' \
| super -z -c 'yield this*2+1' -
Yield is often used to transform records
yield [a,b],[b,a] | collect(this)
{a:1,b:2}
{a:3,b:4}
Loading...
echo '{a:1,b:2}
{a:3,b:4}' \
| super -z -c 'yield [a,b],[b,a] | collect(this)' -