//arrow-core/arrow.core/Ior/bimap

bimap

common inline fun <C, D> bimap(fa: (A) -> C, fb: (B) -> D): Ior<C, D>

Apply fa if this is a Left or Both to A and apply fb if this is Right or Both to B

Example:

import arrow.core.Ior

fun main() {
  Ior.Right(12).bimap ({ "flower" }, { 12 }) // Result: Right(12)
  Ior.Left(12).bimap({ "flower" }, { 12 })  // Result: Left("flower")
  Ior.Both(12, "power").bimap ({ it * 2 }, { b -> "flower $b" })   // Result: Both("flower power", 24)
}

Do you like Arrow?

Arrow Org
<