//arrow-core/arrow.core/Validated/tapInvalid

tapInvalid

common inline fun tapInvalid(f: (E) -> Unit): Validated<E, A>

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

Example:

import arrow.core.Validated

fun main() {
  Validated.Valid(12).tapInvalid { println("flower") } // Result: Valid(12)
  Validated.Invalid(12).tapInvalid { println("flower") }  // Result: prints "flower" and returns: Invalid(12)
}

Do you like Arrow?

Arrow Org
<