title: Swift for in - get entries as reference
body: <p>Is there a way to make the <code>for .. in</code> loop return <strong>references</strong> to the entries of a collection instead of <strong>copies</strong>? </p>
  
  <p>Say I have an array <code>points</code> of <code>CGPoint</code> objects and I want to loop over them and pass each point to a function <code>adjustPoint</code> that can modify the point using an <code>inout</code> parameter. </p>
  
  <p>Now doing the following doesn't work, since the <code>for .. in</code> loop returns the points as immutable / mutable (depending on whether or not I use <code>var</code>) <strong>copies</strong> of the actual points in the array:</p>
  
  <pre><code>for var point in points {
      adjustPoint(point: &amp;point)  // This function only changes the copy
  }
  </code></pre>
  
  <p>Currently, the only way I see to do this is to loop over the index:</p>
  
  <pre><code>for i in 0..&lt;points.count {
      adjustPoint(point: &amp;points[i])
  }
  </code></pre>
  
  <p>Is this really the only way or is it also possible with a <code>for .. in</code> loop? </p>
  
  <p><em>Note:</em> I've read this question which is from quite some time ago (Swift 1 I believe) so I thought maybe they've changed something in the meantime: <a href="https://stackoverflow.com/questions/25793460/turn-for-in-loops-local-variables-into-mutable-variables">turn for in loops local variables into mutable variables</a> </p>