Skip to content

Commit

Permalink
bad copy and paste
Browse files Browse the repository at this point in the history
  • Loading branch information
quii committed Apr 13, 2022
1 parent 892e734 commit eca0412
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion revisiting-arrays-and-slices-with-generics.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ But this won't compile.
The reason is we're trying to reduce to a _different_ type than the type of the collection. This sounds scary, but actually just requires us to adjust the type signature of `Reduce` to make it work. We won't have to change the function body, and we won't have to change any of our existing callers.

```go
func Reduce[A any](collection []A, accumulator func(A, A) A, initialValue A) A {
func Reduce[A, B any](collection []A, accumulator func(B, A) B, initialValue B) B {
var result = initialValue
for _, x := range collection {
result = accumulator(result, x)
Expand Down

0 comments on commit eca0412

Please sign in to comment.