juniorKotlin
What is an if expression in Kotlin?
Updated May 16, 2026
Short answer
if in Kotlin returns a value.
Deep explanation
Unlike Java, Kotlin treats if as an expression that can return values directly.
Real-world example
Choosing higher score in a game app.
Common mistakes
- Expecting ternary operator like Java.
Follow-up questions
- Does Kotlin have ternary operator?
- Can if return block values?