# Programming in Swift: Fundamentals

Oct 19 2021 · Swift 5.5, iOS 15, Xcode 13

## Part 4: More Collections

### Episode complete

Play next episode

Next

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

#### Notes: 31. Working with Sets

Update Notes: The student materials have been reviewed and are updated as of October 2021.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

In this exercise, you’ll learn about a third and final collection type in Swift: sets.

``````var someSet: Set<Int>
``````
``````//let someArray: Array<Int>
//let someDictionary: Dictionary<String, Int>
``````
``````var someSet: Set<Int> = [1, 2, 3, 1]
``````
``````someSet.contains(1)
``````
``````someSet.contains(99)
``````
``````someSet.insert(5)
``````
``````someSet.remove(3)
``````
``````let removedElement = someSet.remove(3)
``````
``````let nilElement = someSet.remove(42)
``````
``````someSet
``````
``````let anotherSet: Set<Int> = [5, 7, 13]
``````
``````let intersection = someSet.intersection(anotherSet)
``````
``````let difference = someSet.symmetricDifference(anotherSet)
``````
``````let union = someSet.union(anotherSet)
``````
``````someSet.form
``````
``````someSet.formUnion(anotherSet)
``````
``````someSet
anotherSet
``````