Skip to main content Link Search Menu Expand Document (external link)

Any

func (input *Channel[T]) Any(predicate func(T) bool) <-chan bool

Any determines if any input value matches the predicate.

If no value matches the predicate, false is sent to the returned channel when all input values have been processed, or the pipeline is canceled.

If instead some value is found to match the predicate, true is immediately sent to the returned channel and no more input values are read.

Examples

output := input.Any(func(value int) bool { return value > 3 })

output := input.Any(func(value int) bool { return value >= 2 })