//arrow-core/arrow.core/Either/mapLeft

mapLeft

common inline fun <C> mapLeft(f: (A) -> C): Either<C, B>

The given function is applied if this is a Left.

Example:

import arrow.core.*

fun main() {
 Either.Right(12).mapLeft { "flower" } // Result: Right(12)
 Either.Left(12).mapLeft { "flower" }  // Result: Left("flower")
}

Do you like Arrow?

Arrow Org
<