Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-swift latest

ControlNotificationStream.contains(where:)

Returns a Boolean value that indicates whether the asynchronous sequence contains an element that satisfies the given predicate.

Source and package
Qualified name
ControlNotificationStream.contains(where:)
Declared in
ControlNotificationStream
Package
libtmux-swift
contains(where: (Self.Element) async throws -> Bool) -> Bool

Inherited from AsyncSequence.contains(where:)

Description#

You can use the predicate to check for an element of a type that doesn’t conform to the Equatable protocol, or to find an element that satisfies a general condition.

In this example, an asynchronous sequence called Counter produces Int values from 1 to 10. The contains(where:) method checks to see whether the sequence produces a value divisible by 3:

let containsDivisibleByThree = await Counter(howHigh: 10) .contains { $0 % 3 == 0 } print(containsDivisibleByThree) // Prints "true"

The predicate executes each time the asynchronous sequence produces an element, until either the predicate finds a match or the sequence ends.

  • Parameter predicate: A closure that takes an element of the asynchronous sequence as its argument and returns a Boolean value that indicates whether the passed element represents a match.
  • Returns: true if the sequence contains an element that satisfies predicate; otherwise, false.
Parameters
Raises
  • any Error – Conditionally propagates errors (rethrows).

Esc

Type to search.

Reference previewOpen reference