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.reduce(into:_:)

Returns the result of combining the elements of the asynchronous sequence using the given closure, given a mutable initial value.

Source and package
Qualified name
ControlNotificationStream.reduce(into:_:)
Declared in
ControlNotificationStream
Package
libtmux-swift
reduce( into: Result, updateAccumulatingResult: (inout Result, Self.Element) async throws -> Void ) -> Result

Inherited from AsyncSequence.reduce(into:_:)

Description#

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 updateAccumulatingResult closure executes sequentially with an accumulating value initialized to initialResult and each element of the sequence.

Prefer this method over reduce(_:_:) for efficiency when the result is a copy-on-write type, for example an Array or Dictionary.

  • Parameters:
    • initialResult: The value to use as the initial accumulating value. The nextPartialResult closure receives initialResult the 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 nextPartialResult closure or returned to the caller.
  • Returns: The final accumulated value. If the sequence has no elements, the result is initialResult.
Type parameters
Parameters
Raises
  • any Error – Conditionally propagates errors (rethrows).

Esc

Type to search.

Reference previewOpen reference