The when statement replaces Java's switch.
Kotlin introduced the when
statement. Let's see an example:
val firstName = "Daniel"
when (firstName) {
"Daniel" -> d("daniel", "welcome, buddy :)")
"Mel" -> d("daniel", "welcome, Mel!")
"Jordan" -> d("daniel", "want to grab dinner?")
}
It can sometimes be useful for determining a given action, and an alternative to the if
and switch
statements.
switch
case statement.Alert tutorial.
Material Design.
Stroke it.
Create beautiful buttons in XML.
Built with Android Studio and Kotlin.
Getting started is sometimes the hardest part.
Add a click listener in Kotlin.
Let users sign in.
It always begins with registration.