getOrElse

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

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
}