//arrow-core/arrow.core/Either/tap

tap

common inline fun tap(f: (B) -> Unit): Either<A, B>

The given function is applied as a fire and forget effect if this is a Right. When applied the result is ignored and the original Either value is returned

Example:

 import arrow.core.*

fun main() {
  Either.Right(12).tap { println("flower") } // Result: prints "flower" and returns: Right(12)
  Either.Left(12).tap { println("flower") }  // Result: Left(12)
}

Do you like Arrow?

Arrow Org
<