title: How do array updates with = work in Scala?
body: <p>I understand that I can write </p>
  
  <pre><code>myArray(index) = newValue
  </code></pre>
  
  <p>to update an array. However, I don't understand how this works internally. I learned from another question here that <code>=</code> is usually not a method call in Scala. I also understand that the brackets are shorthand for calling the <code>apply()</code> method on an object, so I assume <code>myArray(index)</code> means <code>myArray.apply(index)</code>.</p>
  
  <p>But how does it work to assign a value to something that has just been returned from a method call?</p>