1. Arrays
  2. Dictionaries
  3. Closures
  4. Sets

1. Array

It is ordered collection of values

  1. append → Adds to the last index of array
  2. insert → Can add to any index
  3. remove → Removes an element at a specified index or a specific value.
  4. update → Updates the value at a specified index.
  5. Iterate → Loop through the elements of the array.
var randomWords: [String] = ["hello", "world", "fox", "cat", "dog"]
var marks: [Int] = [5, 6, 1, 10, 3]

//returns boolean indicating whether array is empty or not
print(randomWords.isEmpty)
//return no. of elements in the array
print(randomWords.count)
//returns first element, if empty returns "" string
print(randomWords.first ?? "")

//return maximum number of array
print(marks.max() ?? 0)
//return minimum number of array
print(marks.min() ?? 0)

Output

false 5 hello 10 1

you can select index and value by using enumerated.

for (key, value) in randomWords.enumerated() {
    print("\(key) - \(value)")
}

Output