0PricingLogin
Dart Academy · Lesson

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

  1. Sets and Guaranteed Uniqueness
  2. Set Operations: union, intersection, difference
  3. Maps as Key-Value Stores
  4. Iterating Entries, Keys, and Values
← Back to Dart Academy