overridding constructor...how to?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

overridding constructor...how to?

nelson -
hi all,
  in order to override a constructor for my objects, in order to make some initializzation of instance variables, what i have to do? Defining a new methods seems not to work... what i'm doing wrong? Where i can find a useful reference about squeak programming? thanks in advance,
 
nelson


Reply | Threaded
Open this post in threaded view
|

Re: overridding constructor...how to?

Elod Kironsky
Hi!

> hi all,
>   in order to override a constructor for my objects, in order to make
> some initializzation of instance variables, what i have to do?
> Defining a new methods seems not to work... what i'm doing wrong?
> Where i can find a useful reference about squeak programming? thanks
> in advance,
>  
> nelson
>
>------------------------------------------------------------------------
>
>  
>
You have to override the initialize method in your class. BTW: you
should start at www.squeak.org and got through the links. A bunch of
useful information there for newbies too. If you are deriving a class
don't forget to call super initialize, if you want to initialize the
instance variables of the super class.

Elod



Reply | Threaded
Open this post in threaded view
|

Re: overridding constructor...how to?

nelson -




>
You have to override the initialize method in your class. BTW: you
should start at www.squeak.org and got through the links. A bunch of
useful information there for newbies too. If you are deriving a class
don't forget to call super initialize, if you want to initialize the
instance variables of the super class.


thanks :)




Reply | Threaded
Open this post in threaded view
|

Re: overridding constructor...how to?

Wolfgang Helbig-2
In reply to this post by nelson -
> hi all,
>   in order to override a constructor for my objects, in order to make some initializzation of instance variables, what i have to do? Defining a new methods seems not to work... what i'm doing wrong? Where i can find a useful reference about squeak programming? thanks in advance,
>  
> nelson

You can use any class method to create an instance of yout class. For
examples have a look in the system browser Graphics-Display Objects |
Cursor class | instance creation | new" which overrides the new method.
I learned this from Adele Goldberg, "Smalltalk-80 The Language", most of
this 1989 book is still valid in Squeak.

hope this helps,

Wolfgang