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

Simple Messages

Previous pageReturn to chapter overviewNext page

A Simple Message is one that requires no additional information or parameters apart from the message itself. Such messages must begin with a lower case letter and the remainder of the message keyword can consist of any letters or digits or the underscore (_) character. Try displaying the results of the following examples:

5 squared.


Here the message squared is sent to the integer object 5. All messages return an answer of some description and, in this case, it will be 25.

One great thing about Smalltalk is its ability to handle very large numbers of effectively unlimited precision. Try this:

200 factorial


Here are some more message sends:

'mary had a little lamb' asUppercase


The message asUppercase, when sent to a string object, causes a new string to be created with the contents of the original converted to upper case letters. This new string is then answered as the result of the message.

#(3 4 5 6 7) size


The message size, when sent to this array object containing five integers, answers the number of elements in the array, in this case, 5.

The object to which a message is sent is called the receiver. The message itself is sometimes called a message selector (because it selects which operation will be performed) and the result is generally referred to as the answer.