Navigation:  Tutorials > Beginners Guide to Smalltalk > Objects and Messages >

Objects communicate with Messages

Previous pageReturn to chapter overviewNext page

In Smalltalk, objects send messages to one another to cause things to happen. How an object responds to a particular message is determined by the class of object that it is and it is important to realize that not all objects respond successfully to all messages. The set of messages that an object can understand, and its response to these messages, determines the behavior of the object within the Smalltalk system.

All objects know what set of messages they can understand. This set is governed by the class of the object.

The following are typical of messages that might be sent:

+
-
new
show
exit
includes:
asSortedCollection

You can use the Smalltalk language to create objects and send messages to them. Create a new workspace window (File/New) and try the following examples. You should display the result of evaluating each line individually.

3+4

 

'Hello world' reverse

 

5 factorial

 

Tip: Remember that you don't have to select the entire line to do this, just place the insert cursor somewhere on the line and type Ctrl+D (Workspace/Display it) to cause it to be evaluated and the answer displayed.