title: How to assign name to intermediate whilst pattern matching in Scala
body: <p>I'm doing some pattern matching on a colon delimited String as follows:</p>
  
  <pre><code>case s:String =&gt; s.split(":") match {
    case Array("foo","bar") =&gt; ...
    case Array("hello",_,_) =&gt; ...
    ...
  }
  </code></pre>
  
  <p>How can I rearrange the code to assign a name to the array returned by <code>s.split(":")</code>?</p>
  
  <p>I've tried the following to no avail:</p>
  
  <pre><code>case s:String =&gt; val x = s.split(":") match {
    case Array("foo","bar") =&gt; // try to use x here
    ...
  }
  </code></pre>