Slate Living Tutorial

to those about to rock...

Control Flow

Please see the appropriate section in the Slate programmer's manual for more details on control flow.

Boolean and Equality Operators

DescriptionSelectorExample
And/\x /\ y
Or\/x \/ y
Notnotx not
Boolean Equivalenceeqv:x eqv: y
Exclusive Orxor:x xor: y
Greater-than>x > 10
Less-than<3 < y
Equals=x = 6

If Statements

There are several if operators supported in Slate: ifTrue:, ifFalse:, ifNil:, ifNotNil:.

Usage examples:

"Execute a block if the expression is true"
x = 10 ifTrue: [inform: 'x is equal to 10'].

"Execute a block if the expression is false"
y = 0 ifFalse: [inform: 'y is not equal to zero'].

The ifNil: and ifNotNil: operators work in a similar manner. Another very useful operator is ifNotNilDo: which passes its first argument to the block parameter:

(list at: index) ifNil: [...] ifNotNilDo: [| :item | item doSomething].

Case-switch