3.4.2 Set Operations (Union / Intersection / Difference)
Sets support mathematical operations that allow combining and comparing collections.
Union
The union operation:
- Combines elements from multiple sets
- Removes duplicates
- Produces a new set
Intersection
The intersection operation:
- Returns elements common to all sets
- Is useful for finding shared values
Difference
The difference operation:
- Returns elements present in one set but not another
- Helps identify unique elements between groups
📌 Note:
Set operations are efficient and expressive for collection comparison tasks.