Conditional
This section contains functions that check if a slice meets a certain condition. Results are returned as a boolean value.
All
All checks if all elements in a slice meet a certain condition.
Usage:
slice.All([]int{1, 2, 3}, func(v int) bool { return v > 0 }) // true
slice.All([]int{1, 2, 3}, func(v int) bool { return v > 1 }) // false
Any
Any checks if any element in a slice meets a certain condition.
Usage:
slice.Any([]int{1, 2, 3}, func(v int) bool { return v > 0 }) // true
slice.Any([]int{1, 2, 3}, func(v int) bool { return v > 3 }) // false
Contains
Contains checks if a slice contains a certain value.
Usage:
slice.Contains([]int{1, 2, 3}, 1) // true
slice.Contains([]int{1, 2, 3}, 4) // false