
What is an Array?
An array is an ordered list with indices / Index.
Examples of an array are a to-do list, shopping list, Amazon Wish List, etc.
Let’s say we have an array list of apps
Index:
0 1 2 3
Element:
“Reminders” “Mail” “Xcode” “Calendar”
Important Note:
The index of the first element always starts with zero because the way computer scientists deal with data in memory, they have offset & offset starts with zero & that’s why the Array begins with zero. The index of an array never exceeds the number of elements.
Here is how to declare an Array in Swift:
We will declare an array with the let or var keyword, the identifier name, the equal sign, and square brackets. A comma separates each element.
var apps = ["Reminders", "Mail", "Xcode", "Calendar"] // Array of Strings, Each element is of Type String
var number = [1, 2, 300, 4000] // Array of Integers, Each element is of Type Integer
var bools = [true, false, false, true] // Array of Boolean values, Each element is of Type Bool
var groups = [["John", "Tom", "Steve"], ["Brandon", "Bill"]] // Array inside array








