//arrow-core/arrow.core/Either/orNull

orNull

common fun orNull(): B?

Returns the right value if it exists, otherwise null

Example:

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

//sampleStart
val right = Right(12).orNull() // Result: 12
val left = Left(12).orNull()   // Result: null
//sampleEnd
fun main() {
  println("right = $right")
  println("left = $left")
}

Do you like Arrow?

Arrow Org
<