tryFold<U, E extends Object> method
An iterator method that applies a function as long as it returns successfully, producing a single, final value.
Implementation
Result<U, E> tryFold<U, E extends Object>(
U initial, Result<U, E> Function(U, T) f) {
var accum = initial;
for (final res in this) {
final folded = f(accum, res);
if (folded.isErr()) {
return folded.intoUnchecked();
}
accum = folded.unwrap();
}
return Ok(accum);
}