title: Reassigning Elements of Array: Syntax (Ruby)
body: <p>I'm learning the parallel assignment operator in Ruby now. When I tried using it to swap values in an array, I got unexpected results. Couldn't find the answer to this online and was hoping someone can shed the light on what is happening here.</p>
  
  <p>First example:</p>
  
  <pre><code>array = [1,2,3]
  =&gt; [1, 2, 3]
  array[0,1] = array[1,0] 
  =&gt; []
  array
  =&gt; [2, 3] #thought this would be = [2,1,3]
  </code></pre>
  
  <p>Where did array[0] go and why wouldn't Ruby swap the values?</p>
  
  <p>Second example:</p>
  
  <pre><code>array = [1,2,3]
  =&gt; [1, 2, 3]
  array[0,1] = [1,0]
  =&gt; [1, 0]
  array
  =&gt; [1, 0, 2, 3] #was expecting [1,0,3]
  </code></pre>
  
  <p>Why did Ruby insert the right hand side into array and not substitute the values?</p>