Next: , Previous: , Up: Statements   [Contents][Index]


19.10 Case Ranges

You can specify a range of consecutive values in a single case label, like this:

case low ... high:

This has the same effect as the proper number of individual case labels, one for each integer value from low to high, inclusive.

This feature is especially useful for ranges of ASCII character codes:

case 'A' ... 'Z':

Be careful: with integers, write spaces around the ... to prevent it from being parsed wrong. For example, write this:

case 1 ... 5:

rather than this:

case 1...5: