0Pricing
Swift Academy · Lesson

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

  1. Dictionary CRUD and Subscript Access
  2. Iterating and Transforming Dictionaries
  3. Set Operations: Union, Intersection, Difference
  4. Choosing Between Array, Dictionary and Set
← Back to Swift Academy