infix 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: (A) -> 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.