title: Is there a way to bind a variable to multiple alternatives in a switch statement?
body: <p>Suppose I have an enum definition as follows:</p>
  
  <pre><code>enum Response {
      case Result(String, Int)
      case Error(String)
  }
  </code></pre>
  
  <p>Then, I get such a response:</p>
  
  <pre><code>let resp: Response = // ...
  </code></pre>
  
  <p>Suppose I want to write a switch statement and handle the same way the Result and the Error cases and bind a variable of the same name to the <code>String</code> they contain. How can I do this? Conceptually, something similar to this:</p>
  
  <pre><code>switch resp {
      case let .Result(str, _), let .Error(str):
          println("Found: \(str)")
  }
  </code></pre>
  
  <p>where <code>str</code> is bound twice, and <code>_</code> signals that I'm not interested in the <code>Int</code> value that a <code>Result</code> carries.</p>
  
  <p>So far, the closest thing I could find was to declare an inline function like this and then call it:</p>
  
  <pre><code>func processRespString(str: String) {
      println("Found \(str)")
  }
  
  switch resp {
      case let .Result(str, _): processRespString(str)
      case let .Error(str): processRespString(str)
  }
  </code></pre>
  
  <p>Is there a better way?</p>