Swith statement is done by the `case`

in Ruby.

First example:

```
case n
when 0
puts 'You typed zero'
when 1, 9
puts 'n is a perfect square'
when 2
puts 'n is a prime number'
puts 'n is an even number'
when 3, 5, 7
puts 'n is a prime number'
when 4, 6, 8
puts 'n is an even number'
else
puts 'Only single-digit numbers are allowed'
end
```

Second example:

```
score = 70
result = case score
when 0..40 then "Fail"
when 41..60 then "Pass"
when 61..70 then "Pass with Merit"
when 71..100 then "Pass with Distinction"
else "Invalid Score"
end
```

You can also use case impression.

```
puts case a
when 1..5
"It's between 1 and 5"
when 6
"It's 6"
when String
"You passed a string"
else
"You gave me #{a} -- I have no idea what to do with that."
end
```