getOrElse

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

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

Example:

import arrow.core.Either.Right
import arrow.core.Either.Left
import arrow.core.getOrElse

fun main() {
Right(12).getOrElse { 17 } // Result: 12
Left(12).getOrElse { 17 } // Result: 17
}

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


inline 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> Validated<E, A>.getOrElse(default: () -> A): A

Return the Valid value, or the default if Invalid