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 "%%"
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With