reduceOptional abstract method

Optional<T> reduceOptional(
  1. T accumulator(
    1. T,
    2. T
    )
)

Performs a reduction on the elements of this stream, using an associative accumulation function, and returns an Optional describing the reduced value, if any.

Example

final max = GenericStream.of([1, 2, 3, 4, 5])
    .reduceOptional((a, b) => a > b ? a : b);

Implementation

Optional<T> reduceOptional(T Function(T, T) accumulator);