[Newbies] Howto initialize class variables

Alex Schenkman alex at schenkman.info
Sat Mar 20 11:31:47 UTC 2010


Bert your are super!

* never call "super initialize" on the class side

 Why? I thought it was "polite" to do it, =)

On Sat, Mar 20, 2010 at 10:10, Bert Freudenberg <bert at freudenbergs.de>wrote:

> On 20.03.2010, at 09:46, Alex Schenkman wrote:
> > Hi List!
> >
> > I'm playing with class variables. How should I initialize them?
> > I've tried with the class method initialize but it does not do the job.
> >
> > Pirulo class>>initialize
> >     super initialize.
> >     myClassVar := Dictionary new at: 'one' put: 1.
>
> * never call "super initialize" on the class side
> * class variables should be capitalized
> * class initializers need to be executed manually
> * they are only executed automatically when loading the class (e.g. file-in
> or via Monticello)
>
> So this would be right:
>
> Pirulo class>>initialize
>    "self initialize"
>     MyClassVar := Dictionary new at: 'one' put: 1.
>
> The "self initialize" comment is conventionally put there so you can easily
> double-click after the opening quotes to select the whole expression, and
> do-it. You need to do it any time you change the initialize method. This
> works because when evaluating code in a Browser, "self" refers to the
> currently selected class.
>
> - Bert -
>
>
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20100320/ecfbb447/attachment.htm


More information about the Beginners mailing list