ControlNotificationStream.drop(while:)
Swift
- Python Unavailable
- Ruby Unavailable
- Lua Unavailable
- TypeScript Unavailable
- Rust Unavailable
- Go Unavailable
- Java Unavailable
- .NET Unavailable
- C++ Unavailable
- Swift
- Declared in
- ControlNotificationStream
- Package
- libtmux-swift
- methodasync ¶drop(while:)
-
Inherited from
AsyncSequence.drop(while:)Omits elements from the base asynchronous sequence until a given closure returns false, after which it passes through all remaining elements.
Use
drop(while:)to omit elements from an asynchronous sequence until the element received meets a condition you specify.In this example, an asynchronous sequence called
CounterproducesIntvalues from1to10. Thedrop(while:)method causes the modified sequence to ignore received values until it encounters one that is divisible by3:let stream = Counter(howHigh: 10) .drop { $0 % 3 != 0 } for await number in stream { print(number, terminator: " ") } // Prints "3 4 5 6 7 8 9 10 "
After the predicate returns
false, the sequence never executes it again, and from then on the sequence passes through elements from its underlying sequence as-is.- Parameter predicate: A closure that takes an element as a parameter and returns a Boolean value indicating whether to drop the element from the modified sequence.
- Returns: An asynchronous sequence that skips over values from the base sequence until the provided closure returns
false.
Discussed in Context managers
0 declared, 0 inherited