//arrow-core/arrow.core/getOrHandle

getOrHandle

common inline fun <A, B> Either<A, B>.getOrHandle(default: (A) -> B): B

Returns the value from this Right or allows clients to transform Left to Right while providing access to the value of Left.

Example:

import arrow.core.Either.Right
import arrow.core.Either.Left
import arrow.core.getOrHandle

fun main() {
  Right(12).getOrHandle { 17 } // Result: 12
  Left(12).getOrHandle { it + 5 } // Result: 17
}

Do you like Arrow?

Arrow Org
<