Last active
July 10, 2020 15:26
-
-
Save zeroarst/6aa0bf958c268b8361de4b80d72f8d93 to your computer and use it in GitHub Desktop.
Chaining Kotlin Type Casting and following execution together!! (1)
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
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