October 2025
Intermediate to advanced
100 pages
2h 27m
English
That let block looks like it handles the result of the whole if expression—but things aren’t as they appear. In fact, the let function is part of the first else branch. When the first racer wins, we take the if branch, and the else section containing the let and println functions never runs.
The three possible outcomes in this race look like three different branches in a single cascading if expression. There’s an if branch for when the first racer is faster, an else if branch for when the second racer comes out on top, and finally an else branch for when neither racer wins.

But that’s not how the Kotlin compiler sees ...
Read now
Unlock full access