Test if variable matches any of several strings w/o long if-elsif chain, or case-when
Perhaps you didn’t know that you can put multiple conditions on a single case: case mystr when “abc”, “def”, “ghi”, “xyz” .. end But for this specific string-based test, I would use regex: if mystr =~ /\A(?:abc|def|ghi|xyz)\z/ If you don’t want to construct a regex, and you don’t want a case statement, you can create … Read more