Loading section...

Difference: Elements Unique to One Set

The difference of two sets returns elements that are in the first set but not in the second. This operation answers the question "what is in A that is not in B?" Unlike union and intersection, difference is not symmetric: A - B gives different results than B - A. The order matters because you are asking a directional question. Think of difference as starting with all elements of the first set, then removing any element that also appears in the second set. What remains are elements unique to the first set. This is extremely useful for finding what is new, what is missing, what was added, or what was removed. Starting with all employees, we first remove those on vacation, then remove those working remotely. The result shows who is physically in the office. This kind of filtering is natural w