when case > number ruby code example
Example 1: ruby case statement
case {condition}
when {option1}
#do something
when {option2}
#do something
else #default
#do something else
end
Example 2: ruby case
case fruit
when 'Apple'
# something
when 'Banana' then puts 'Right' # only if it is one line
else #default
# something
end