by Example

Arrays


Arrays are declared using the bracket notation




To create an empty array use the initializer syntax



var groceries = [
    "Milk", "Bread", "Butter", "Honey"
]


var nums = [Int]()

print("Grocery list: \(groceries)")
$ swift .swift
Grocery list: ["Milk", "Bread", "Butter", "Honey"]


Next: Dictionaries (Maps)