Stupid Question?

Norbert Hartl norbert at hartl.name
Wed Jan 16 14:46:21 UTC 2008


On Wed, 2008-01-16 at 08:46 -0500, Richard Eng wrote:
> I have a stupid question:  How do you pass information into the #initialize
> method at object creation time? You can't use any of the instance methods or
> accessors because they don't yet exist! So how do you pass information in?

You do not! :) If you want to pass values into an object you
may do this with your own constructor for the object. This
contructor creates a new object and passes some values to
it.

Example:

MyObject class>>on: aStream
   ^ self new
      stream: aStream

in your code you do:

myObject := MyObject on: aStream

hope this helps,

Norbert




More information about the Squeak-dev mailing list