Last active
February 6, 2022 16:03
-
-
Save arsalankhan994/dfadc6ec325c012937c7dc64059b9071 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() { | |
// Smart Casting | |
var studentWithRealObject: Any? = Student() | |
if (studentWithRealObject is Student) { | |
println("Student name: ${studentWithRealObject.name}") | |
println("Student age: ${studentWithRealObject.age}") | |
} | |
} | |
data class Student( | |
val name: String = "Erselan Khan", | |
val age: Int = 27 | |
) { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment