Sometimes, a message needs additional information to perform its work. Certain messages, called Binary Messages, require two objects; the receiver and one parameter. Try:
3 + 4
6 * 5
5 squared + 6
4 ** 3
The latter ** message selector represents exponentiation, so this expression computes 4 to the power 3. Here, the integer object 4 is the receiver and 3 is the single parameter required by the ** message.
As you can see, binary messages are often used to perform arithmetic in Smalltalk. The message selectors consist of one or more special characters that are not letters or digits. They can be used for other operations too:
'skin' , 'diver'
The , message is used for concatenation. In this case it is used to append the string 'diver' to the receiving object, the string 'skin'. The operation answers a new string that contains the concatenation of the two source strings. In fact, this message can be used to concatenate many similar collections of objects:
#(1 2 3) , #(4 5 6)
Sometimes, messages are used simply to "construct" a new object. We'll hear more about these constructor or class messages later but here is an interesting example using the binary message. @:
(50 @ 150) class
The @ message, when sent to an integer, is used to create a two-dimensional point object. The class message simply asks the resultant object to answer what class it is (we'll learn more about classes later). The interesting thing here is that the sequence 50@150 appears, in the Smalltalk language, to represent a two-dimensional point, but, it's important to understand that the @ symbol is not part of the language per se. Rather, it is simply a message that performs a particular operation (in this case the creation of a point object) just like any other binary message. Just for fun, try some more operations on points.
(50 @ 150) + (25 @ 35)
(640 @ 480) * 3