title: Scala: match and parse an integer string?
body: <p>I'm looking for a way to matching a string that may contain an integer value. If so, parse it. I'd like to write code similar to the following:</p>
  
  <pre><code>  def getValue(s: String): Int = s match {
         case "inf" =&gt; Integer.MAX_VALUE 
         case Int(x) =&gt; x
         case _ =&gt; throw ...
    }
  </code></pre>
  
  <p>The goal is that if the string equals "inf", return Integer.MAX_VALUE. If the string is a parsable integer, return the integer value. Otherwise throw.</p>