Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify in the manual how map_values() behaves differently from map(). #2473

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions docs/content/manual/manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -892,8 +892,12 @@ sections:
element of the input array, and return the outputs in a new
array. `map(.+1)` will increment each element of an array of numbers.

Similarly, `map_values(x)` will run that filter for each element,
but it will return an object when an object is passed.
To transform an object using filter `x`, use `map_values(x)`.
When an object is passed to `map_values(x)`,
it will run that filter for each value in the object,
leaving the keys unchanged.
When any other type of value is passed to it, `map_values(x)`
behaves the same as `map(x)`.

`map(x)` is equivalent to `[.[] | x]`. In fact, this is how
it's defined. Similarly, `map_values(x)` is defined as `.[] |= x`.
Expand Down