Skip to content

Commit

Permalink
Update slice.go
Browse files Browse the repository at this point in the history
  • Loading branch information
samber authored Aug 9, 2024
1 parent 6a44ef6 commit b838b86
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ func ForEach[T any](collection []T, iteratee func(item T, index int)) {
}

// ForEachWhile iterates over elements of collection and invokes iteratee for each element
// collection return value decide to continue or break ,just like do while()
// collection return value decide to continue or break, like do while().
// Play: https://go.dev/play/p/QnLGt35tnow
func ForEachWhile[T any](collection []T, iteratee func(item T, index int) (goon bool)) {
for i := range collection {
if !iteratee(collection[i], i) {
Expand Down

0 comments on commit b838b86

Please sign in to comment.