1 Answers
when keyword is like switch keyword in C language. Below is the code, how to use when keyword in Kotlin.
fun main(args:Array<String>){
val num : Int = 2
when(num)
{
1 -> println(“It is one”)
2 -> println(“It is two”)
3 -> println(“It is three”)
4 -> println(“It is four”)
else -> println(“Give the proper input”)
}
}