Skip to content

Commit ffcca2e

Browse files
authored
Fix swapped closure parameters
As per [`reduce` command documentation examples][reduce], the reduce closure has parameters `|it, acc|`. This accidental swap was part of the introduction of the example in nushell#1928. [reduce]: https://www.nushell.sh/commands/docs/reduce.html
1 parent ce4ea51 commit ffcca2e

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lang-guide/chapters/types/basic_types/closure.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ The `reduce` command processes a list to accumulate a single result. The closure
177177
[1 2 3 4] | reduce { |accumulator, current_value| $accumulator + $current_value }
178178
```
179179

180-
_Explanation:_ This sums the numbers in the list. The closure `{|accumulator, current_value| $accumulator + $current_value}` adds the `current_value` to the `accumulator`. By default, the first item is the initial accumulator, and iteration starts from the second.
180+
_Explanation:_ This sums the numbers in the list. The closure `{|current_value, accumulator| $accumulator + $current_value}` adds the `current_value` to the `accumulator`. By default, the first item is the initial accumulator, and iteration starts from the second.
181181

182182
**Output:**
183183

0 commit comments

Comments
 (0)