tryReduce method
T?
tryReduce(
- T combine(
- T,
- T
Tries to reduce the iterable, returning null if the iterable is empty.
Exceptions thrown by combine (including Error subclasses such as
StackOverflowError) propagate to the caller — only the
StateError("No element") from reducing an empty iterable is caught.
Implementation
T? tryReduce(T Function(T, T) combine) {
if (isEmpty) return null;
return reduce(combine);
}