Last active
July 21, 2020 02:18
-
-
Save janakaaleph/e1041d02b8b8117a924e35f775cd3c99 to your computer and use it in GitHub Desktop.
If and When in Kotlin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun main() { | |
println("If Expression") | |
val a = 100 | |
val b = 200 | |
/** | |
* COMPILATION ERROR: 'if' must have both main and 'else' branches if used as an expression. | |
*/ | |
val maxValue = if (b > a) "b is greater" | |
println("Greater value = $maxValue") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment