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

var arrayName: [String] = []

Example

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

main.swift

var fruits: [String] = []
print(fruits)

Output

Swift - Create Empty String Array
ADVERTISEMENT

Conclusion

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