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

bimap

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:

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

Do you like Arrow?

Arrow Org
<