Understanding Messages: Sequence and Cascade

Damien Cassou, St├ęphane Ducasse and Luc Fabresse http://stephane.ducasse.free.fr

Expression Sequence

. is a separator

    expression1.
    expression2.
    expression3

Example

    Transcript cr.
    Transcript show: 1.
    Transcript show: 2

Expression Sequence

    | macNode pcNode |
    macNode := Workstation withName: #mac.
    macNode sendPacket: 'Hello World'

Cascade: Sending Multiple Messages to an Object

    Transcript cr.
    Transcript show: 1.
    Transcript show: 2

is equivalent to:

    Transcript
        cr ;
        show: 1 ;
        show: 2

Cascade Example

Sending Multiple Messages to an Object

    | c |
    c := OrderedCollection new.
    c add: 1.
    c add: 2

is equivalent to:

    OrderedCollection new
        add: 1 ;
        add: 2 

What You Should Know

/