In lesson 17 of ProfStef I am stuck on the command which says.
"Try to go to the next lesson with a cascade of two 'next' messages:"
What is the correct answer for these?
This is an example of the cascade syntax. You can use this syntax when you want to send two (or more) messages to the same receiver object:
rcvr msg1.
rcvr msg2
can be abreviated to rcvr msg1; msg2
.
In this case the idea is to send #next
to ProfStef
twice, which can be shortened to ProfStef next; next
.
Note that this syntax makes more sense when the receiver is an expression (compared with the example where the receiver is just a variable)
<some Smalltalk expression> msg1; msg2.
Without this possibility you would have to introduce a local variable:
var := <some Smalltalk expression>.
var msg1.
var msg: 2
which is more verbose. Note also that the messages occurring in the cascade may have arguments. Let's finally say that the answer if the cascade is the answer of its last message.