Skip to content

Instantly share code, notes, and snippets.

@arsalankhan994
Created February 6, 2022 15:50
Show Gist options
  • Save arsalankhan994/4fc953a7c8369cd1167aadeb909ac8f1 to your computer and use it in GitHub Desktop.
Save arsalankhan994/4fc953a7c8369cd1167aadeb909ac8f1 to your computer and use it in GitHub Desktop.
fun main() {
// Type Checking
// Initializing list with String, Int and Boolean value
val list = listOf<Any>("Erselan Khan", 21, false)
// loop on above list
list.forEach {
when(it) {
is String -> println("String value is: $it")
is Int -> println("Int value is: $it")
is Boolean -> println("Boolean value is: $it")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment