Swift Language Declaring Sets


Example

Sets are unordered collections of unique values. Unique values must be of the same type.

var colors = Set<String>()

You can declare a set with values by using the array literal syntax.

var favoriteColors: Set<String> = ["Red", "Blue", "Green", "Blue"]
// {"Blue", "Green", "Red"}