Swift – Create Empty String Array

To create an empty string array in Swift, specify the element type String for the array and assign an empty array to the String array variable.

The syntax to create an empty string array is

</>
Copy
var arrayName: [String] = []

Example

In the following program, we will create an empty String array, named fruits.

main.swift

</>
Copy
var fruits: [String] = []
print(fruits)

Output

Swift - Create Empty String Array

Conclusion

In this Swift Tutorial, we learned how to create an empty string array.