Instance Method


Publishes a Boolean value upon receiving an element that satisfies the throwing predicate closure.


func tryContains(where predicate: @escaping (Upstream.Output) throws -> Bool) -> Publishers.TryContainsWhere<Publishers.Share<Upstream>>



A closure that takes an element as its parameter and returns a Boolean value indicating whether the element satisfies the closure’s comparison logic.

Return Value

A publisher that emits the Boolean value true when the upstream publisher emits a matching value.


This operator consumes elements produced from the upstream publisher until the upstream publisher produces a matching element. If the closure throws, the stream fails with an error.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software