getOrElse method

R getOrElse(
  1. R defaultValue()
)

Returns the value from this Right or the given argument if this is a Left.

Example

Right<int, int>(12).getOrElse(() => 17); // Result: 12
Left<int, int>(12).getOrElse(() => 17);  // Result: 17

Implementation

R getOrElse(R Function() defaultValue) => _foldInternal(
      ifLeft: (_) => defaultValue(),
      ifRight: _identity,
    );