Gumiku
11/03/2021, 5:51 AMval name: String? = null
name?.let {
Box() {
}
} ?: println("hello")
Tobias Suchalla
11/03/2021, 6:45 AMJean-Luc D.
11/03/2021, 6:53 AMxx?.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.Gumiku
11/03/2021, 7:54 AM