[Newbies] new and initialize

Ron Teitelbaum ron at usmedrec.com
Tue May 10 18:20:11 UTC 2016


Hi Joe,

Excellent question.  Try this.  

Object new. 

Highlight it and do debug it.   Click "Into" to go into the #new method.

Notice the implementation of #new.  

You should be able to see there that #initialize is called automatically.
 
Also for extra points notice what class new is implemented on.  What method should you call to skip initialize?

All the best,

Ron Teitelbaum



> -----Original Message-----
> From: beginners-bounces at lists.squeakfoundation.org [mailto:beginners-
> bounces at lists.squeakfoundation.org] On Behalf Of Joseph Alotta
> Sent: Tuesday, May 10, 2016 2:07 PM
> To: beginners at lists.squeakfoundation.org
> Subject: [Newbies] new and initialize
> 
> Greetings,
> 
> I have an instance method called ‘initialize’ that defines instance variables.
> 
> I want it to run whenever a new instance is created.  How do I accomplish
> that?
> 
> I tried to add a class method ‘new’  that contained ^(super new) initialize.
> But it warned me about adding the message saying it would have serious
> effects.
> 
> So where do I put it?
> 
> Sincerely,
> 
> Joe.
> 
> 
> 
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners



More information about the Beginners mailing list