Instantiation

Objects are instances of their class. Usually, we send the message #new to a class for creating an instance of this class.
The message #allInstances sent to a class answers an Array with all instances of this class.
For example, let’s look at how many instances of SimpleButtonMorph exist:

SimpleButtonMorph allInstances size.

0

Now create a new instance of it:

SimpleButtonMorph new
label: ‚A nice button‘;
openCenteredInWorld.

a SimpleButtonMorph(777874944)

See the button centered on the world ? The list of all instances should contains one more instance:

Pharo environment

Pharo is full of objects. There are windows, text, numbers, dates, colors, points and much more. You can interact with objects in a much more direct way than is possible with other programming languages. Every object understands the message ‚explore‘. As a result, you get an Explorer window that shows details about the object.

Date today explore.

17 March 2017

This shows that the date object consists of a point in time (start) and a duration (one day long).

ProfStef explore.

ProfStef

You see, ProfStef class has a lot of objects. Let’s take a look at my code:

ProfStef browse.

a Nautilus

FAQ

What does 0 @ 0 mean?

0@0 represents a Point object with x and y coordinates both set to 0.

In fact, 0@0 sends the message @ to the number 0 with argument 0. The effect will be that the number 0 will ask the Point class to create a new instance with coordinates (0,0).