Skip to content

Commit bac134f

Browse files
Fixing the reduceWithIndex documentation (rescript-lang#426)
* Fixing the reduceWithIndex documentation The order of the parameters documentation was wrong, reduceWithIndex callback will receive the accumulator first, item from the array and then the index of the item * Update pages/docs/manual/latest/api/belt/array.mdx * Update pages/docs/manual/latest/api/belt/array.mdx * Update pages/docs/manual/latest/api/belt/array.mdx Co-authored-by: Patrick Ecker <[email protected]>
1 parent 661bedd commit bac134f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pages/docs/manual/latest/api/belt/array.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -763,12 +763,12 @@ let reduceWithIndexU: (array<'a>, 'b, (. 'b, 'a, int) => 'b) => 'b
763763
let reduceWithIndex: (array<'a>, 'b, ('b, 'a, int) => 'b) => 'b
764764
```
765765

766-
`reduceWithIndex(xs, f)`
766+
`reduceWithIndex(arr, init, f)`
767767

768-
Applies `f` to each element of `xs` from beginning to end. Function `f` has three parameters: the item from the array and an accumulator, which starts with a value of `init` and the index of each element. `reduceWithIndex` returns the final value of the accumulator.
768+
Applies `f` to each element of `arr` from beginning to end. Function `f` has three parameters: an "accumulator", which starts with a value of `init` and the item from the array and the index of each element. `reduceWithIndex` returns the final value of the accumulator.
769769

770770
```res example
771-
Belt.Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, x, i) => acc + x + i) == 16
771+
Belt.Array.reduceWithIndex([1, 2, 3, 4], 0, (acc, value, i) => acc + value + i) == 16
772772
```
773773

774774
## someU

0 commit comments

Comments
 (0)