Classes

Method Abstract():init() Foundation

Method for instance object initialization.

Syntax
:init( [<paramList,...>] ) --> self
Parameters
<paramList>
The parameters passed to the :new() method are also passed to :init().
Return

The method returns the object executing the method.

Description

The method :init() can optionally be declared within the class declaration (between the CLASS...ENDCLASS statements). If it is declared, it is executed immediately after calling the class method :new(), i.e. as soon as a new instance of the class (the new object) is created. The method is used to initialize instance variables of the object with default values. If :init() is declared, it must be implemented for the class. The same arguments are passed to the instance method :init() as to the class method :new(). Within the source code of the method :init(), the object can be referenced through the variable self. The operator :: can also be used (as an abbreviation for self:) to send a message to the object.

When a class is derived from other classes (superclasses), and the superclasses have their own :init() methods, the :init()method of each such superclass must be explicitly called from within the subclass :init():, by using the superclasses name. However, if :init() is not declared in a subclass, the :init() method of the superclass is implicitly executed when an object of the subclass is created.

Feedback

If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.