Ruby Case Expression

Watch out! This tutorial is over 2 years old. Please keep this in mind as some code snippets provided may no longer work or need modification to work on current systems.

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.

Continue reading