instance variable accessing its owner
ned at squeakland.org
Wed Jun 23 04:46:03 UTC 2004
On Tuesday 22 June 2004 8:39 pm, Cancerbero wrote:
> Suppose that obj1 is an instance variable of the class C and has the
> instance variable inst1. My question is how inst1 could have access
> to obj1?
When we have two objects that have to know about each other, we do this
In the case of an object making another object that should know about it, we
usually have the owner construct the object and then tell the newly
constructed object about the owner.
It doesn't matter whether the owner holds on to the new object in an instance
variable or somewhere else; the pattern is the same.
Something like this would work (it uses instance variables on both objects):
inst1 := SomeClass new.
inst1 owner: self.
myOwner := anObject
By the way, there are several Spanish-speaking Squeak and Smalltalk users'
More information about the Squeak-dev