//arrow-core/arrow.core/Option/tapNone

tapNone

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

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

Example:

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

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

Do you like Arrow?

Arrow Org
<