I'd like to hold a property of type X that extends Y, the getter should return Y and setter should be private and accept X.
Is this possible via a simple var definition, or do I need to use fun ?
Consider using additional backing property:
class Sample {
private var privateX: X
var publicY: Y
get() = privateX
}
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