Marius Kotsbak
12/23/2021, 11:58 AMthan_
12/23/2021, 12:31 PMNullable.zip
🙂Marius Kotsbak
12/23/2021, 3:21 PMYoussef Shoaib [MOD]
12/24/2021, 12:48 PMAny?
also accepts Any
than_
12/24/2021, 12:51 PMval e1: Either<A,B>
val e2: Either<A,B>
e1.zip(e2, ::Pair)
Youssef Shoaib [MOD]
12/24/2021, 12:53 PMthan_
12/24/2021, 1:01 PMimport arrow.core.Either
import arrow.core.zip
inline fun <A,B, R> A?.zip(b: B?, f: (A, B) -> R): R? =
this?.let{ aa -> b?.let{bb -> f(aa,bb)}}
val e1 = Either.Right(1)
val e2 = Either.Left(Unit)
null.zip(2, ::Pair).let(::println)
e1.zip(e2, ::Pair).let(::println)
it's gonna print
null // as expected
(Either.Right(1), Either.Left(kotlin.Unit)) // yikes :D