tryForEach<E extends Object> method

Result<(), E> tryForEach<E extends Object>(
  1. Result<(), E> f(
    1. T
    )
)

An iterator method that applies a fallible function to each item in the iterator, stopping at the first error and returning that error.

Implementation

Result<(), E> tryForEach<E extends Object>(Result<(), E> Function(T) f) {
  for (final res in this) {
    final result = f(res);
    if (result.isErr()) {
      return result.intoUnchecked();
    }
  }
  return const Ok(());
}