You have already learnt about arrays and loops in previous tutorials. In this tutorial, we're going to dive deeper into these two topics.
Review of arrays
Array's are written within square brackets [ ]. Use the .count attribute to get number of elements inside the array and square brackets [index] to access data of that specific index. Remember the first element is at index 0.
type=codeblock|id=swift_arrays_review|autocreate=swift4var colors = ["red", "blue", "green"]print(colors[0]) // redprint(colors[2]) // greenprint(colors.count) // 3
Assignment with an = on Array's makes a copy.
var b = colors // copies the Array onto the new variable
The "empty array" is just an empty pair of brackets [ ]. The + works to append two arrays, so [1, 2] + [3, 4] yields [1, 2, 3, 4] (this is just like + with strings).