octopus/pkg/utils/collections.go

20 lines
315 B
Go
Raw Permalink Normal View History

2023-03-22 22:45:17 +08:00
package utils
func Any[T any](items []T, predicate func(T) bool) bool {
for _, item := range items {
if predicate(item) {
return true
}
}
return false
}
func All[T any](items []T, predicate func(T) bool) bool {
for _, item := range items {
if !predicate(item) {
return false
}
}
return true
}