title: Boolean check if a string matches a regex in ruby?
body: <p>In ruby, I have seen a lot of code doing things like:</p>
  
  <pre><code>def test(s)
    s =~ /Macintosh/
  end
  </code></pre>
  
  <p>to test whether or not a string matches a regex. However, this returns a fixnum or nil, depending on if it finds a match. Is there a way to do the same operation, but have it return a boolean as to whether or not it matched?</p>
  
  <p>The two possible solutions that I thought of were <code>!(s =~ /Macintosh/).nil?</code> and <code>!(s !~ /Macintosh/)</code>, but neither of those seem very readable. Is there something like:</p>
  
  <pre><code>def test(s)
    s.matches?(/Macintosh/)
  end
  </code></pre>