Ruby Convert If Statements to Case

case, if-statement, ruby, switch-statement

Solution

case
  when (a % 3).zero? then puts "%3"
  when (a % 4).zero? then puts "%4"
  when (a % 7).zero? && (a % 13).zero? then puts "%%"
end

Problem

Is it possible to use a case statement to replace these if statements? ``` if (a%3 == 0) then puts "%3" elsif (a%4 == 0) then puts "%4" elsif (a%7 == 0 && a%13 == 0) then puts "%%" ```

Original source