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

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


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

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

common 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.



default the default expression.

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

Return the Valid value, or the default if Invalid

Do you like Arrow?

Arrow Org