arrow-core-data / arrow.core / getOrElse

getOrElse

inline fun <B> EitherOf<*, B>.getOrElse(default: () -> B): B

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

Example:

Right(12).getOrElse(17) // Result: 12
Left(12).getOrElse(17)  // Result: 17

inline fun <A, B> Ior<A, B>.getOrElse(default: () -> B): Binline fun <T> Option<T>.getOrElse(default: () -> T): T

Returns the option’s value if the option is nonempty, otherwise return the result of evaluating default.

Parameters

default - the default expression.inline fun <E, A> ValidatedOf<E, A>.getOrElse(default: () -> A): A

Return the Valid value, or the default if Invalid

Do you like Arrow?

Arrow Org
<