3 ms·
Read-only properties would be implemented as methods that return the value of an internal variable. There should be no way to directly access the internal state
by jakobegger 8y ago
Read-only properties would be implemented as methods that return the value of an internal variable. There should be no way to directly access the internal state of an object, even if it is read-only -- because that would prevent you from changing internal details (eg. do you store the property in a float or a double?), breaking the "encapsulation".
- edwinyzh 8y agoSure, if not implemented as methods that return the value of an internal variable, how can one achieve the "readonly" goal?