Skip to content

Instantly share code, notes, and snippets.

@janakaaleph
Last active July 21, 2020 02:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save janakaaleph/e1041d02b8b8117a924e35f775cd3c99 to your computer and use it in GitHub Desktop.
Save janakaaleph/e1041d02b8b8117a924e35f775cd3c99 to your computer and use it in GitHub Desktop.
If and When in Kotlin
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