Set Operations: Union, Intersection, Difference
Performing mathematical set algebra and membership tests efficiently.
Welcome
A `Set` stores unique, unordered values conforming to `Hashable`. It supports efficient mathematical set operations: union, intersection, difference, and more.
Creating Sets
```swift
var fruits: Set = ["apple","banana","cherry"]
var inferred: Set = [1, 2, 3, 3, 2] // {1,2,3} — duplicates removed
```
Sets are written like arrays but have type `Set`.
All lessons in this course
- Dictionary CRUD and Subscript Access
- Iterating and Transforming Dictionaries
- Set Operations: Union, Intersection, Difference
- Choosing Between Array, Dictionary and Set