Swift – Create an Empty Set
To create an empty set in Swift, use
T is the type of elements we would like to store in this Set.
The following statements are some of the examples to create empty set.
var strs = Set<String>() var nums = Set<Int>()
In the following program, we will initialize an empty Set that stores Strings.
var names = Set<String>() print(names)
Now, let us create an empty Set that stores Integers.
var names = Set<Int>() print(names)
In this Swift Tutorial, we have learned how to create an Empty Set, in Swift programming.