orNull method

R? orNull()

Returns the Right's value if it exists, otherwise null.

Example

Right<int, int>(12).orNull(); // Result: 12
Left<int, int>(12).orNull();  // Result: null

Implementation

R? orNull() => _foldInternal(
      ifLeft: _const(null),
      ifRight: _identity,
    );