I’m pretty sure ruby has an idiom for that.
I just have too many places in my code where I say
if (x == A) || (x == B) || (x ==C)
do_something
else
do_something_else
end
I know I also could do
case x
when A, B, C
do_something
else
do_something_else
end
but I prefer using if else if there’s a nice idiom to make it more succinct.
You can tidy up your
casestatement a bit more like thisor if it is a repeating pattern, roll it into a method on
Objectthen use it as