title: Assign multiple variables at once in scala
body: <p>I have the following code:</p>
  
  <pre><code>val text = "some text goes here"
  val (first, rest) = text.splitAt(4)
  println(first + " *" + rest)
  </code></pre>
  
  <p>That works fine.</p>
  
  <p>However, I want to have two cases, defining "first" and "rest" outside, like this:</p>
  
  <pre><code>val text = "some text goes here"
  var (first, rest) = ("", "")
  if (text.contains("z")) {
    (first, rest) = text.splitAt(4)
  } else {
    (first, rest) = text.splitAt(7)
  }
  println(first + " *" + rest)
  </code></pre>
  
  <p>But that gives me an error:</p>
  
  <pre><code>scala&gt;      | &lt;console&gt;:2: error: ';' expected but '=' found.
           (first, rest) = text.splitAt(4)
  </code></pre>
  
  <p>Why is it an error to do (first, rest) = text.splitAt(4) but not to do val (first, rest) = text.splitAt(4)? And what can I do?</p>
  
  <p>Edit: Can't re-assign val, changed to var. Same error</p>