-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
Description
I found the foreach
example a little hard to understand. Can we have something more Hello World-ish?, eg
https://jqplay.org/s/4GNwRCpQLX
jq 'foreach .[] as $item (0; . + 1; "\(.) - \($item)")'
input: ["apple", "banana", "cherry"]
output:
"1 - apple"
"2 - banana"
"3 - cherry"
Also, i'm curious why it starts at 1, not 0 -- this seems different than a foreach loop, eg, in JavaScript or Python. Would you be able to explain (here and/or in the docs)? Is this a bug?
(speaking of JavaScript, the "s" is not capitalized in the docs)
Thanks!
arielelkin, manfredliuactive, dgrothaus-mc, bderusha, SandraRodgers and 2 more