Swift Language Checking whether a set contains a value


Example

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

You can use the contains(_:) method to check whether a set contains a value. It will return true if the set contains that value.

if favoriteColors.contains("Blue") {
    print("Who doesn't like blue!")
}
// Prints "Who doesn't like blue!"