getOrElse method

T getOrElse(
  1. T defaultValue()
)

If the Result is Ok, provides a default value; otherwise, executes the error function.

Implementation

T getOrElse(T Function() defaultValue) {
  return fold(
    (value) => value,
    (error) => defaultValue(),
  );
}