An Empty array requires an explicit type.
i.e let ar: [Int] = []
var ages: [int] = [23, 45, 67, 82, 1, 23, 43]
this array will contain all integers. For array just type the type of data in square brackets.
Type declaration ⇒ where the data type is mentioned and if any other datais present it will return an error.
Type inference ⇒ where the data type is not mentioned and any data type can be used in an array.
let friend1 = "Saad"
let friend2 = "Ali"
let friend3 = "Ahmed"
let friend4 = "Hasan"
let friend5 = "Kabil"
let friendlist = [friend1, friend2, friend3, friend4, friend5]
print(friendlist[2])
output
Ahmed