title: Swapping two vars in scala
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/1624484/tuple-parameter-declaration-and-assignment-oddity">Tuple parameter declaration and assignment oddity</a>  </p>
  </blockquote>
  
  
  
  <p>In python I can do</p>
  
  <pre><code>&gt;&gt;&gt; (a,b) = (1,2)
  &gt;&gt;&gt; (b,a) = (a,b)
  &gt;&gt;&gt; (a,b)
  (2, 1)
  </code></pre>
  
  <p>But in scala:</p>
  
  <pre><code>Welcome to Scala version 2.8.1.final (OpenJDK Server VM, Java 1.6.0_20).
  Type in expressions to have them evaluated.
  Type :help for more information.
  
  scala&gt; var (a,b) = (1,2)
  a: Int = 1
  b: Int = 2
  
  scala&gt; (a,b)=(b,a)
  &lt;console&gt;:1: error: ';' expected but '=' found.
         (a,b)=(b,a)
              ^
  </code></pre>
  
  <p>So while I can initialise vars as a tuple, I cannot assign them as a tuple. Any way to get around this, other than using a tmp var?</p>