The ruby case
statement is similar to the C/C++/Java switch
, but more directly related to the similar (and superior) structures from Pascal and Ada. First, it assumes that each case ends where the next one starts, without needing a break
to terminate a case. Secondly, each case can be expressed rather generally, with a single value, a range of value, or a list containing some of each.