Conditions with `if`
Learn how to use Kotlin's `if` conditions as well as comparison and logical operators.
We'll cover the following...
We'll cover the following...
For conditional control flow, Kotlin uses the if and when keywords. The syntax of if-blocks is the same as in C and Java. Similarly, the when keyword is similar to switch in these languages but more powerful, as you will learn.
Conditions using if #
Conditions with if can be written as follows:
Each condition is followed by a block of code in curly braces. There can be any number of else-if blocks (including zero) and up to one else-block.
Note: In the else-block, the planet variable is included in the output string using string interpolation. To do so, you just ...