reduceOrNone method

Option<T> reduceOrNone(
  1. T combine(
    1. T value,
    2. T element
    )
)

Reduces the collection to a single value by iteratively combining elements. Returns the result as a Some, or None if the Iterable is empty.

Implementation

Option<T> reduceOrNone(T Function(T value, T element) combine) {
  if (isEmpty) return const None();
  return Some(reduce(combine));
}