# If you want to check whether a string matches a regular expression, # but not return the match data, you can just use === the case equality operator. # Bad !! ('foobar' =~ /bar/) #=> true !! ('foo' =~ /bar/) #=> false # Good /bar/ === 'foobar' #=> true /bar/ === 'foo' #=> false # This makes sense if you think about it in a case statement and === for RegExp. case 'foobar' when /foo/ "makes sense" end # Implementing === on String to match RegExp is less sensical. case /foo/ when 'foobar' "doesn't make sense" end