Last active
November 17, 2019 21:36
-
-
Save magdamiu/307da58d61f941905172d87b2e66f47b to your computer and use it in GitHub Desktop.
when
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
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