Ruby's case statement uses ===
by default. Is there a way to make it use 'equals to' (i.e. ==
) instead?
The motivation for doing so is because I have 5 if
statements that would very nicely be replaced by a switch, but I was a little surprised to learn that
datatype = "string".class
if datatype == String
puts "This will print"
end
is not the same as
case datatype
when String
puts "This will NOT print"
end