Instance Variable Selection



next up previous contents index
Next: Field Selection Up: Expressions Previous: Class Constructors

Instance Variable Selection

Within a class (10.4) and its module (10.1), the instance variables of objects of the class can be accessed directly using the form

[<expr> "."] <idn>
where the type of the expr is the class type (10.4), and idn is the name of an instance variable of that class. If the expr is omitted, it defaults to self (10.4); i.e., within a method of the class, the instance variables of self can be named directly.

Outside a class's module, the instance variables of an object of the class cannot be accessed directly; they can only be accessed indirectly, by invoking methods on the object.



theta-questions@lcs.mit.edu