Home Segments Index Top Previous Next

377: Mainline

To create an instance of an array, you send the new: message to the Array class, with the number of elements in the array supplied as the argument.

The following, for example, creates a four-location Array instance, and assigns that instance to a global variable, Calories:

                   *-- Tells the Array class 
                   |   to create a new instance 
                   | 
                   |   *-- Specifies that the instance 
                   |   |   is to contain four elements 
                   v   v 
Calories := Array new: 4