December 2014
Beginner
300 pages
8h 9m
English
You can create an array by declaring a variable to hold the array and then telling Swift exactly what is going to be in that array. Here’s how you do that:
var myFirstArray:Array<Int> = Array<Int>()
Here you declare the variable myFirstArray, and you declare the variable to be of type Array<Int>. This says that the array is an array of integers. You then set myFirstArray equal to a new array of integers by adding an empty set of parentheses at the end.
Note
Of course you can write this verbose array syntax, but so you will very rarely see arrays written this way because Swift has type inference.
Read now
Unlock full access