nacyolsa
09/13/2024, 7:00 AMlet
with multiple variables. I think it was called zip()
. What happened to it? It is mentioned here https://stackoverflow.com/questions/35513636/multiple-variable-let-in-kotlin#comment124559417_35522422 but docs were moved and I can't find it.Alejandro Serrano.Mena
09/13/2024, 7:08 AMlet
+ destructuring can get you a long way
Pair(3, "hello").let { (number, string) -> ... }
nacyolsa
09/13/2024, 7:30 AMAlejandro Serrano.Mena
09/13/2024, 7:36 AMRaise
block, something like:
fun Pair<A?, B?>.let(transform: (A, B) -> C): C? = nullable {
val a = first.bind()
val b = second.bind()
transform(a, b)
}
nacyolsa
09/13/2024, 7:40 AMnullable
use exceptions to handle nullable variables?Alejandro Serrano.Mena
09/13/2024, 7:40 AMphldavies
09/13/2024, 10:45 AMraise
uses untraced exceptions (that is, no stacktrace is populated at instantiation) unless explicitly requested via traced {}
so in this case there is very little overhead to the exception usage within nullable { }