EitherX<K, V> extension

Extension on Either<K, V> providing additional utility methods.

This extension adds methods to Either<K, V> objects, allowing for more expressive handling of Either types, particularly in scenarios where the value might be null.

on
  • Either<K, V>

Methods

flatMapOrNull<R>(Either<K, R> f(V)) → Either<K, R>?

Available on Either<K, V>, provided by the EitherX extension

Applies a function returning an Either to the value if the Either is Right; otherwise, returns null.
getOrNull() → V?

Available on Either<K, V>, provided by the EitherX extension

Returns the value if the Either is Right; otherwise, returns null.
getValueOrElse(V defaultValue) → V

Available on Either<K, V>, provided by the EitherX extension

Returns the value if the Either is Right; otherwise, returns the provided default value.
mapOrNull<R>(R f(V)) → R?

Available on Either<K, V>, provided by the EitherX extension

Applies a function to the value if the Either is Right; otherwise, returns null.