 <p>This is indeed expected behaviour – and it's due to the fact that an array in Swift (unlike <code>NSArray</code>) is a value type, meaning that it gets copied when passed about. Although as <a href="http://stackoverflow.com/a/37998340/2976878">@MartinR points out</a>, due to the copy-on-write behaviour of value types, the <em>actual</em> copy of the array will be done when you come to mutate it – although this is an optimisation that shouldn't affect how you think about value types.</p> <p>Therefore when you enumerate over an array, be it with <code>forEach()</code> or <code>for ... in</code> – you're actually iterating over a <em>copy</em> of that array. This works through using an <code>Iterator</code> (or <code>Generator</code> pre-Swift 3). What's happening behind the scenes when you iterate over a collection looks something like this:</p> <pre><code>let collection = [1, 2, 3, 4] var iterator = collection.makeIterator() // next() will return the next element, or nil if it's reached endIndex while let element = iterator.next() { // do something with the element } </code></pre> <p>In the case of an <code>Array</code>, an <code>IndexingIterator</code> is returned for <code>makeIterator()</code> – which will iterate through the elements by keeping track of an index, incrementing it each time you call <code>next()</code>, and returning the element at that given index – until you reach <code>endIndex</code>. (you can see its <a href="https://github.com/apple/swift/blob/master/stdlib/public/core/Collection.swift#L364" rel="nofollow">exact implementation here</a>).</p> <p>The array that you're iterating over is kept as a property of <code>IndexingIterator</code>, therefore ensuring that you're enumerating on a copy – but mutating the original. </p> <p>This therefore means that it's perfectly safe to mutate a value-typed collection while enumerating over it. The enumeration will iterate over the full length of the collection (as it works on the copy) – completely independant of any mutations you do to the original.</p>