orLazy method

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

Evaluates otherBlock only when this result is an error.

Use this method for lazy fallback composition. Unlike or and operator |, the callback is not invoked when this result is successful.

Implementation

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

  return otherBlock();
}