getOrHandle method

R getOrHandle(
  1. R defaultValue(
    1. L value
    )
)

Returns the value from this Right or allows clients to transform the value of Left to the final result.

Example

Right<int, int>(12).getOrHandle((v) => 17);   // Result: 12
Left<int, int>(12).getOrHandle((v) => v + 5); // Result: 17

Implementation

R getOrHandle(R Function(L value) defaultValue) => _foldInternal(
      ifLeft: defaultValue,
      ifRight: _identity,
    );