Ruby Case
Ruby CASE
The Ruby CASE statement syntax and example.
Ruby CASE syntax
case expression when expression [, expression ...] [then] -- Ruby code else -- Ruby code end
Ruby CASE example
x = 3 case when x == 1 puts "false" when x == 3 puts "x = 3, true" else puts "Else block" end
Output
x = 3, true