Swift provides a third collection type called Set. Set is not frequently used, purely by convention, but we do not think that this should be the case. This chapter will introduce Set and show off some of its unique advantages.
A Set is an unordered collection of distinct instances.
This definition sets it apart from an Array, which is ordered and can accommodate repeated values.
For example, an array could have the content
[2,2,2,2], but a set cannot.
A Set has some similarities to a Dictionary, but it is also a little different. Like a dictionary, a set’s values are unordered within the collection. Similar to the requirement that a dictionary’s keys must be unique, Set does not allow repeated ...