We can initialize an array with an array literal. An array literal is a set of values that prepopulate the array. The following example shows how to define an immutable array of integers using the let keyword:
let arrayOne = [1,2,3]
As mentioned, if we need to create a mutable array, we will use the var keyword to define the array. The following example shows how to define a mutable array:
var arrayTwo = [4,5,6]
In the preceding two examples, the compiler inferred the type of values stored in the array by looking at the type of values stored in the array literal. If we want to create an empty array, we will need to explicitly declare the type of values to store in the array. There are two ways to declare ...