Home » Ruby Case

Ruby Case Statement

In Ruby, we use ‘case’ instead of ‘switch’ and ‘when’ instead of ‘case’. The case statement matches one statement with multiple conditions just like a switch statement in other languages.

Syntax:

Example:

Output:

Ruby switch 1

Look at the above output, conditions are case sensitive. Hence, the output for ‘Saturday’ and ‘saturday’ are different.


Next TopicRuby for loop

You may also like