arrow-core-data / arrow.core / Ior / leftOrNull

leftOrNull

fun leftOrNull(): A?

Returns the Left value or A if this is Left or Both and null if this is a Right.

Example:

import arrow.core.Ior

//sampleStart
val right = Ior.Right(12).leftOrNull()         // Result: null
val left = Ior.Left(12).leftOrNull()           // Result: 12
val both = Ior.Both(12, "power").leftOrNull()  // Result: 12
//sampleEnd

fun main() {
  println("right = $right")
  println("left = $left")
  println("both = $both")
}

Do you like Arrow?

Arrow Org
<