Help - Glossary - C - Cascade

A cascade is a way to send the same object a series of messages, without too much typing. Here is an example:

| sum |
sum := (2 sin)+(2 sin).
"The sum of twice to sin, it would seem."
Transcript cr; cr; show: 'The sum is '; show: sum.

This declares the variable 'sum', and then assigns that variable to the sum of the sinus of 2 and of 3. On the third line, the Transcript is send a series of messages: Twice cr, which is to say a new line; followed by the message to show the string 'The sum is ' followed by a message to show the sum found at line 2.

The cascading is done with " ; " and amounts to "use the last receiver". To write the same without cascading:

| sum |
sum := (2 sin)+(2 sin).
Transcript cr.
Transcript cr.
Transcript show: 'The sum is '.
Transcript show: sum.

It is often useful not to type too much, but one's code does get a little less explicit.

Glossary - C