title: bubble sorts array parameter
body: <p>I have the following code that bubble sorts the array parameter.</p>
  
  <pre><code>   def bubble_sort(arr)
        sorted = false
        until sorted
          sorted = true
          (arr.count - 1).times do |i|
            if arr[i] &gt; arr[i + 1]
              arr[i], arr[i + 1] = arr[i + 1], arr[i]
              sorted = false
            end
          end
        end
  
        arr
      end
  </code></pre>
  
  <p>I want to understand specifically this line: <code>arr[i], arr[i + 1] = arr[i + 1], arr[i]</code></p>
  
  <p>say in this case <code>arr[i] = 1 and arr[i+1] = 3</code></p>
  
  <p>The expression would be in all intents and purposes <code>1, 3 = 3, 1</code></p>
  
  <p>Obviously that would give me an error, so I'm assuming this works only when valued are assigned to variables. </p>
  
  <p>However, it still seems counter-intuitive to me. I would expect the code: <code>arr[i], arr[i + 1] = arr[i + 1], arr[i]</code> to give me an error. Is there anyone that can help me reason why this is a valid expression?</p>