title: Is there a reason that Swift array assignment is inconsistent (neither a reference nor a deep copy)?
body: <p>I'm reading the documentation and I am constantly shaking my head at some of the design decisions of the language.  But the thing that really got me puzzled is how arrays are handled.</p>
  
  <p>I rushed to the playground and tried these out.  You can try them too.  So the first example:</p>
  
  <pre><code>var a = [1, 2, 3]
  var b = a
  a[1] = 42
  a
  b
  </code></pre>
  
  <p>Here <code>a</code> and <code>b</code> are both <code>[1, 42, 3]</code>, which I can accept.  Arrays are referenced - OK!</p>
  
  <p>Now see this example:</p>
  
  <pre><code>var c = [1, 2, 3]
  var d = c
  c.append(42)
  c
  d
  </code></pre>
  
  <p><code>c</code> is <code>[1, 2, 3, 42]</code> BUT <code>d</code> is <code>[1, 2, 3]</code>.  That is, <code>d</code> saw the change in the last example but doesn't see it in this one.  The documentation says that's because the length changed.</p>
  
  <p>Now, how about this one:</p>
  
  <pre><code>var e = [1, 2, 3]
  var f = e
  e[0..2] = [4, 5]
  e
  f
  </code></pre>
  
  <p><code>e</code> is <code>[4, 5, 3]</code>, which is cool.  It's nice to have a multi-index replacement, but <code>f</code> STILL doesn't see the change even though the length has not changed.</p>
  
  <p>So to sum it up, common references to an array see changes if you change 1 element, but if you change multiple elements or append items, a copy is made.</p>
  
  <p>This seems like a very poor design to me.  Am I right in thinking this?  Is there a reason I don't see why arrays should act like this?</p>
  
  <p><em>EDIT</em>: Arrays have changed and now have value semantics.  Much more sane!</p>