Skip to content

Instantly share code, notes, and snippets.

@sasssass
Last active October 23, 2023 13:16
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 sasssass/73b99f6bba3feec6650a11cf37d2071a to your computer and use it in GitHub Desktop.
Save sasssass/73b99f6bba3feec6650a11cf37d2071a to your computer and use it in GitHub Desktop.
polymorphism.kt
open class Parent() {
open fun doSth() {
print("I'm Parent")
}
}
class Child() : Parent() {
override fun doSth() {
print("I'm Child")
}
}
fun main() {
val obj : Parent = Child()
obj.doSth()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment