Skip to content

Commit

Permalink
rename ForEachCondition() to ForEachWhile()
Browse files Browse the repository at this point in the history
  • Loading branch information
Sianao committed Jul 2, 2024
1 parent c6f0028 commit c154e18
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ func ForEach[T any](collection []T, iteratee func(item T, index int)) {
}
}

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

0 comments on commit c154e18

Please sign in to comment.