Hi , does anyone know why println("hello") will no...
# compose
g
Hi , does anyone know why println("hello") will not be called if there is a composable inside the ?.let{}
Copy code
val name: String? = null
name?.let {
      Box() {

      }
} ?: println("hello")
t
https://kotlinlang.slack.com/archives/CJLTWPH7S/p1635538540095300 Seems to be a bug, see thread for workarounds.
j
xx?.let { } ?:
is not always the same as
if (xx != null) { } else { }
the return value of
let
is the return value of the lambda. In your case, the Box statement. Since it doesn't return null, the print statement will never be executed.
g
thanks