title: Ruby on Rails regexp equals-tilde vs. array include for checking a list of options
body: <p>I'm using Rails 3.2.3 with Ruby 1.9.3p0.</p>
  
  <p>I'm finding that I often have to determine whether a string occurs in a list of options. It seems I can use the Ruby array <a href="http://www.ruby-doc.org/core-1.9.3/Array.html#method-i-include-3F" rel="noreferrer"><code>.include</code> method</a>:</p>
  
  <pre><code>&lt;% if ['todo','pending','history'].include?(params[:category]) %&gt;
  </code></pre>
  
  <p>or the regular expression <a href="http://www.ruby-doc.org/core-1.9.3/Regexp.html#method-i-3D-7E" rel="noreferrer">equals-tilde match shorthand</a> with vertical bars separating options:</p>
  
  <pre><code>&lt;% if params[:category] =~ /todo|pending|history/ %&gt;
  </code></pre>
  
  <p>Is one better than the other in terms of performance? </p>
  
  <p>Is there an even better approach?</p>