Although this is not the exact equivalent of a == b || a == c a == b || a == c , the case offers syntax for this:
case a when b, c then puts "It b or c." else puts "It something else." end
Remember to open the nearest Ruby tutorial and read about how the case statement works. Spoiler: it works by calling the #=== method for the compared objects:
a = 42 b, c = Object.new, Object.new def b.=== other; puts "b#=== called" end def c.=== other; puts "c#=== called" end
Now run
case a when b, c then true else false end
This gives you great flexibility. This requires work in the back office, but after you do this, it looks like magic in the front office.
Boris Stitnicky
source share