Navigation:  Appendix A: Jumping Into Smalltalk >

Control Structures

Previous pageReturn to chapter overviewNext page

Smalltalk has no control structures like if built into the language. Instead, Smalltalk uses messages sent to the true or false objects.



if (tries > 5)
return "Too many tries";
return "Trying again";

tries > 5
ifTrue: [^'Too many tries']
ifFalse: [^'Trying again']

Notice that the ^ returns from the method, not just the block.