34,333
edits
Changes
→Why Use a switch Statement?
== Why Use a switch Statement? ==
For a small number of logical evaluations of a value the ''if ... else if ...'' construct outlined in [[10.Objective-C Flow Control Using with if and else]] is perfectly adequate. Unfortunately, any more than two or three possible scenarios can quickly make such a construct both time consuming to write and difficult to read. As a case in point consider the following code example. The program is designed to evaluate integer between 0 and 5 entered at the keyboard and to output the word version of the number (zero, one, two etc):
<pre>