Why this code isnt working? Everything is ok, but after else, idk why code in not working. | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
0

Why this code isnt working? Everything is ok, but after else, idk why code in not working.

fun main() { var mNumber = 1 when (mNumber) { 1 -> println("this is 1") 2 -> println("this is 2") } else -> { println("this is not 1 or 2") } }

3rd Jan 2023, 10:54 AM
Delniya Safavi
1 Resposta
+ 1
put the else inside the brackets as you did for 1 and 2
3rd Jan 2023, 6:33 PM
Ion Kare
Ion Kare - avatar