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

Sending Messages on top of Messages

Previous pageReturn to chapter overviewNext page

When you send a message to a receiver, you always receive another object back as the answer. It seems perfectly reasonable that you should be able to send further messages to this answer. Try:

20 factorial displayString

 

Here, the message displayString, is sent to the result of 20 factorial. Look carefully, and you'll see that what is displayed is surrounded by single quote marks, thus indicating that the integer result has been converted to a text string representation. Perhaps we might additionally want to know how many characters are in the display string for 20 factorial:

20 factorial displayString size

 

So you can see that you can use sequences of messages to create more complex expressions.