In Swift, an array stores values of the same type in an ordered list.
To create an empty array of a certain type, we can use the initializer syntax:
var name = [Type]()
Suppose we want to create an empty array called
scores of the type
var scores = [Int]()
Now that we’ve initialized the
scores array, we can add integers (and only integers) inside.
Note: Arrays can only store items of the same data type. The type of the array cannot be changed after it’s declared.
We’ll also figure out how to remove, change, and manipulate the array later on, but let’s start with creating one.
Create an empty array named
subwayChild of the type
Then print it out.