//arrow-core/arrow.core/Option/tap

tap

common inline fun tap(f: (A) -> Unit): Option<A>

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

Example:

import arrow.core.Some
import arrow.core.none

fun main() {
  Some(12).tap { println("flower") } // Result: prints "flower" and returns: Some(12)
  none<Int>().tap { println("flower") }  // Result: None
}

Do you like Arrow?

Arrow Org
<