zip
inline fun <E, A, B, C> Outcome<E, A>.zip(other: Outcome<E, B>, f: (A, B) -> C): Outcome<E, C>(source)
Zip allows you to combine two or more Outcome
s easily with a supplied function.
Present(2).zip(Present(3)) { a, b -> a + b } // Present(5)
Present(2).zip(Absent) { a, b -> a + b } // Absent
Present(2).zip(Failure("nup")) { a, b -> a + b } // Failure("nup")
Content copied to clipboard
inline fun <E, A, B, C, D> Outcome<E, A>.zip(o1: Outcome<E, B>, o2: Outcome<E, C>, crossinline f: (A, B, C) -> D): Outcome<E, D>(source)