Ruby =~ vs === Operators
<p>I had mostly been using <code>===</code> for matching values to patterns in Ruby. Recently, I discovered that the language also supports the <code>=~</code> operator for regular expressions.</p>

<p>The <a href="http://ruby-doc.org/core-2.3.0/Object.html" rel="nofollow" title="Ruby Documentation">Ruby Documentation</a> defines <code>===</code> as "case equality" and <code>=~</code> as "pattern match".</p>

<blockquote>
  <p>Case Equality – For class Object, effectively the same as calling #==, but typically overridden by descendants to provide meaningful semantics in case statements.</p>
  
  <p>Pattern Match—Overridden by descendants (notably Regexp and String) to provide meaningful pattern-match semantics.</p>
</blockquote>

<p>By experimentation, I find that <code>===</code> works for regular expressions, class names, literal values, and even ranges, while <code>=~</code> only seems to return useful values for regular expressions. My question is: why would I ever use <code>=~</code>? It seems like <code>===</code> supports everything <code>=~</code> does and then some. Is there something I'm missing here that <code>=~</code> is intended to do differently?</p>