Accessing private fields in a data class method

Category |  Applicable to |  Description |  Limitations


Category:

Top

RPL


Applicable to:

Top

All Versions


Description:

Top

The field name (or instance variable) is visible within the scope of an instance of the class. See page 7 of the RPL guide.

For example if you have a Sequence class "MySequence", containing a field "myField" which was private, then you could define a unary instance method "getMyField" on that class to read it:

 getMyField
 | |
 ^ myField

and and a keyword method "storeMyField: aValue" to write to it:

 storeMyField: aValue
 | |
 myField := aValue.
 ^ myField.

Limitations:

Top

None


 

Copyright © 1999, ObjecTime Limited.