I am wondering what it means to declare private[this]
in an object definition? It makes sense to me in a class definition, but in object?
as in:
object Test {
private[this] val t: Int = 5
}
what difference does it have compare to:
object Test {
private val t: Int = 5
}
It is significant when the object is a companion object of a class. In that case the member that is declared private[this]
may be accessed by the object but not instances of the corresponding class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With