ControlNotificationStream.reduce(into:_:)
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
- reduce(into:_:) ( into : Result , updateAccumulatingResult : (inout Result, Self.Element) async throws -> Void ) Resultmethodasync ¶methodasync ¶reduce(into:_:)
-
Inherited from
AsyncSequence.reduce(into:_:)Returns the result of combining the elements of the asynchronous sequence using the given closure, given a mutable initial value.
Use the
reduce(into:_:)method to produce a single value from the elements of an entire sequence. For example, you can use this method on a sequence of numbers to find their sum or product.The
updateAccumulatingResultclosure executes sequentially with an accumulating value initialized toinitialResultand each element of the sequence.Prefer this method over
reduce(_:_:)for efficiency when the result is a copy-on-write type, for example anArrayorDictionary.- Parameters:
- initialResult: The value to use as the initial accumulating value. The
nextPartialResultclosure receivesinitialResultthe first time the closure executes. - updateAccumulatingResult: A closure that combines an accumulating value and an element of the asynchronous sequence into a new accumulating value, for use in the next call of the
nextPartialResultclosure or returned to the caller.
- initialResult: The value to use as the initial accumulating value. The
- Returns: The final accumulated value. If the sequence has no elements, the result is
initialResult.
- Raises
- Parameters:
0 declared, 0 inherited