andLazy method

Result<T, E> andLazy(
  1. Result<T, E> otherBlock()
)

Evaluates otherBlock only when this result is successful.

Use this method for lazy sequential composition. Unlike and and operator &, the callback is not invoked when this result is an error.

Implementation

Result<T, E> andLazy(Result<T, E> Function() otherBlock) {
  if (this is Err<T, E>) return this;

  return otherBlock();
}