Set Operations: union, intersection, difference
Combine and compare sets.
Sets Do Math
Sets borrow ideas from math. With three small methods you can combine or compare them like circles in a Venn diagram. 🔵
Meet union
The union method merges two sets into one. Every item from both appears, and duplicates collapse to a single copy.
var a = {1, 2};
var b = {2, 3};
print(a.union(b));All lessons in this course
- Sets and Guaranteed Uniqueness
- Set Operations: union, intersection, difference
- Maps as Key-Value Stores
- Iterating Entries, Keys, and Values