Skip to content

Instantly share code, notes, and snippets.

@zeroarst
Last active July 10, 2020 15:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zeroarst/6aa0bf958c268b8361de4b80d72f8d93 to your computer and use it in GitHub Desktop.
Save zeroarst/6aa0bf958c268b8361de4b80d72f8d93 to your computer and use it in GitHub Desktop.
Chaining Kotlin Type Casting and following execution together!! (1)
abstract class Animal
class Cat : Animal() {
fun say() = "meow"
}
fun main() {
val myCat: Animal = Cat()
println((myCat as? Cat)?.say())
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment