Accessing Slots

Accessing a Nonexistent Slot

You will not get an error if you try to access a nonexistent slot. If the slot isn't in a frame, the return value is nil. Consider a frame, v, that does not have a foo slot:

v := {name: "Neil", height: 73.25, children: 3};
Print(v.foo);
Accessing a nonexistent slot results in the value nil; Print prints nil.

Because of this, you cannot use the dot operator to distinguish between non-existent slots and existing slots whose values are nil. To distinguish between the two, you must use the techniques discussed in "Slot Existence" on page 48.


An online version of Programming for the Newton using Macintosh, 2nd ed. ©1996, 1994, Julie McKeehan and Neil Rhodes.

Last modified: 1 DEC 1996