[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
Constructor Messages
Constructor messages are used to create new instances of a class. The
default constructor message, new(), is implemented by Class(y) and
inherited by all classes.
When a constructor message is sent to a class object, Class(y) creates a
new, empty object of that class and sends the init() message to it, to
initialize it. The init method is referred to as an initializer
method, and is discussed in the next section.
All arguments passed to the constructor are passed in turn to the init
method to allow it to initialize the object correctly.
When the initializer method returns, the constructor returns the new
object to the caller. It is thus not necessary for the initializer method
to return a value, although by convention, methods which do not return a
value return self.
It is possible to define constructors other than new(). This can be
useful when there is more than one way to initialize the objects of a
class. For more information, see the section Alternate Constructors.
See Also:
Initializer Methods
Alternate Constructors
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson