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

Get the right value B of this Either, or compute a default value with the left value A.

import arrow.core.Either
import arrow.core.getOrElse
import io.kotest.matchers.shouldBe

fun test() {
Either.Left(12).getOrElse { it + 5 } shouldBe 17

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

inline fun <T> Option<T>.getOrElse(default: () -> T): T(source)

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



the default expression.

inline fun <E, A> Validated<E, A>.getOrElse(default: () -> A): A(source)

Return the Valid value, or the default if Invalid