I have a string variable that can only contain 6 different values. I want to check if it contains one of the first four values ββor one of the two second values.
Is there a more elegant way than this:
if string.eql? 'val1' || string.eql? 'val2' || string.eql? 'val3' || string.eql? 'val4' ... elsif string.eql? 'val5' || string.eql? 'val6' ... end
Perhaps something like if string is in ['val1', 'val2', 'val3', 'val4'] ?
source share