Swift: Test if an array is empty

Here we create 2 arrays and one of them empty to test out our code.

var array1: [String: Int] = ["Eng": 90, "Math": 80,"History":85]
if array1.isEmpty {
    print("empty.")
} else {
    print("not empty.")
}

var array2 = [Int]()
if array2.isEmpty {
    print("empty.")
} else {
    print("not empty.")
}

swift

Series Navigation<< Swift: Getting the average
Swift: Printing an incrementing number >>