The subscript syntax is used to retrieve values from an array. Subscript syntax, for an array, is where a number appears between two square brackets, and that number specifies the location (index) within the array of the element we wish to retrieve. The following example shows how to retrieve elements from an array using the subscript syntax:
let arrayOne = [1,2,3,4,5,6] print(arrayOne) //Displays '1' print(arrayOne) //Displays '4'
In the preceding code, we begin by creating an array of integers that contains six numbers. We then print out the value at indexes 0 and 3.