Skip to content

Instantly share code, notes, and snippets.

@magdamiu

magdamiu/KotlinBasics.kt

Last active Nov 17, 2019
Embed
What would you like to do?
when
val firstValue = 6
val secondValue = 3
val operator = "/"
val resultOfOperation = when (operator) {
"+" -> firstValue + secondValue
"-" -> firstValue - secondValue
"*" -> firstValue * secondValue
"/" -> firstValue / secondValue
else -> "$operator operator is invalid."
}
println(resultOfOperation) // => 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment