set in swift
let setExample: Set = ["Apple", "Orange", "Banana", "Apple"] if setExample.contains("Apple") { print("Its healthy") } print(setExample) // OUTPUT: //Its healthy //["Orange", "Apple", "Banana"]
Source: developer.apple.com
Create a Set in Swift
// create a set of integer type var studentID : Set = [112, 114, 116, 118, 115] print("Student ID: \(studentID)")