flat Map
FlatMap allows multiple Outcome
s to be safely chained together, passing the value from the previous as input into the next function that produces an Outcome
fun <A, E, C> Outcome<E, A>.flatMap(f: (A) -> Outcome<E, C>): Outcome<E, C>
Content copied to clipboard
Present(5).flatMap {
if (it < 5) {
Present(it)
} else if (it < 10) {
Absent
} else {
Failure("Value too high")
}
}
Content copied to clipboard