Any returns true if at least one element in the slice satisfies the predicate. Returns false for nil or empty slices. This is a pure function that does not modify the input slice.
(slice []T, predicate func(T) bool)
| 68 | // Returns false for nil or empty slices. |
| 69 | // This is a pure function that does not modify the input slice. |
| 70 | func Any[T any](slice []T, predicate func(T) bool) bool { |
| 71 | return slices.ContainsFunc(slice, predicate) |
| 72 | } |
| 73 | |
| 74 | // Deduplicate returns a new slice with duplicate elements removed. |
| 75 | // The order of first occurrence is preserved. |
no outgoing calls