I want to access animals class color from dogs reference
as I am new to kotlin if something is wrong guide me
fun main() {
var dogs = Dogs("pug")
println("Color of Dog :${dogs.color}")//Black
println("Color of Animal:${}")//White
}
private open class Animals {
open var color: String = "White"
}
private class Dogs(var breed: String) : Animals() {
override var color: String = "Black"
}
Read more here: https://stackoverflow.com/questions/65839402/how-to-access-parent-class-variable-from-child-if-it-is-overriden-it-in-child-cl
Content Attribution
This content was originally published by Arya at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.