I tried to do something like the following:
val a: Int? = 1
val b: Int? = 1
a?.plus(b)
but it doesn't compile cause plus expects an Int.
I also tried to create a biLet function:
fun <V1, V2, V3> biLet(a: V1?, b: V2?, block: (V1, V2) -> V3): V3? {
return a?.let {
b?.let { block(a, b) }
}
}
and use it like that:
val result = biLet(a, b) { p1, p2 -> p1 + p2 }
but it seems a lot of work for something apparently simple. Is there any simpler solution?