Is `a?.let{} ?: run{}` idiomatic in Kotlin?
It’s dangerous to conflate foo?.let { bar(it) } ?: baz() with if (foo != null) bar(foo) else baz(). Say you have a function: fun computeElements(): List<Int>? = emptyList() Consider this code: val maxElement = computeElements()?.let { it.max() } ?: return println(“Max element was $maxElement”) Compared to: val list: List<Int>? = computeElements() val maxElement = if … Read more