Skip to content

Commit

Permalink
Merge pull request #73 from sourcegraph/iter/fix-example-determinism
Browse files Browse the repository at this point in the history
iter: fix non-deterministic example
  • Loading branch information
bobheadxi authored Jan 17, 2023
2 parents ee6e48f + 0979df3 commit f9df11e
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions iter/iter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ func ExampleIterator() {
}

iterator.ForEach(input, func(v *int) {
if *v%2 == 0 {
fmt.Println(*v)
if *v%2 != 0 {
*v = -1
}
})

fmt.Println(input)
// Output:
// 2
// 4
// [-1 2 -1 4]
}

func TestIterator(t *testing.T) {
Expand Down

0 comments on commit f9df11e

Please sign in to comment.