The following results in "Unresolved reference" compiler error for colour
fun main() {
Tomato().printInfo()
}
class Tomato(){
val features = object {
val colour = "red"
}
fun printInfo(){
println("The tomato is: ${features.colour}")
}
}
However, if I make the features object private ( ie. private val features = object ...
) the code works. What is the reason behind this?
(Kotlin 1.8.21)