-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
Using a version of jq with pick/1:
$ jq -nc '[[10,20],30] | pick(first) '
[[10,20]]
./jq -nc '[[10,20],30] | pick(.[length-1])'
[null,30]
$ jq -nc '[[10,20],30] | pick(last) '
jq: error (at <unknown>): Out of bounds negative array index
$ jq -nc '[[10,20],30] | pick(.[-1]) '
jq: error (at <unknown>): Out of bounds negative array index
So the failure of pick(last)
could be resolved by redefining def last: .[length-1];
but is there a better solution? It's not clear to me why pick(.[-1]) should fail.