Created
February 12, 2022 13:20
-
-
Save arsalankhan994/4a1b3eb53ca045103a88668ef2126d67 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
fun main() { | |
// Multi Condition in Kotlin using when/else | |
val list = listOf("Erselan Khan", 27, "[email protected]") | |
when(list[(list.indices).random()]) { | |
"Erselan Khan" -> println("name is ${list[0]}") | |
27 -> println("age is ${list[1]}") | |
"[email protected]" -> println("email is ${list[2]}") | |
else -> println("Else condition") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment