1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

Add def f($arg): syntax (fix #524)

This commit is contained in:
Nicolas Williams
2014-08-08 18:00:47 -05:00
parent fc52e78ed4
commit 32c08d48f3
6 changed files with 44 additions and 77 deletions

View File

@@ -1931,9 +1931,13 @@ sections:
If you want the value-argument behaviour for defining simple
functions, you can just use a variable:
def addvalue(f): f as $value | map(. + $value);
def addvalue(f): f as $f | map(. + $f);
With that definition, `addvalue(.foo)` will add the current
Or use the short-hand:
def addvalue($f): ...;
With either definition, `addvalue(.foo)` will add the current
input's `.foo` field to each element of the array.
Multiple definitions using the same function name are allowed.