2D array Swift goes out of bounds when appending arrays : <p>I want to append elements from one 2D array to the another 2D array, but I get fatal error index out of bound. </p>

<p>the code is as follows: </p>

<pre><code> var array  =  [["a", "b", "c"], ["d","e","f"],["g","h","i"]]

var array2 = [[String]]()
var x = array.count
var y = array[1].count

for j in 0..&lt;x {
    for i in 0..&lt;y {
        array2[j].append(array[j][i])
    }
}
print(array2)
</code></pre>

<p>please don't tell me to just copy the array as this is not what I need, I am using this procedure to do something more complex than just copying an array.</p>

<p>Any suggestions as to why it goes out of bounds?</p>

<p>thanks</p>
