BoxSetSymmetricDifference
Compute the symmetric difference (A \u25b3 B) of two Sets, returning the elements that are in exactly one of the two Sets but not in both.
Equivalent to {@code (A \u222a B) \u2212 (A \u2229 B)}. The result is a new Set of the same variant as A; neither input is modified.
Method Signature
BoxSetSymmetricDifference(set=[set], otherSet=[any])Arguments
Argument
Type
Required
Description
Default
set
set
true
The first set (A).
otherSet
any
true
The second set (B). Accepts any value castable to a Set.
Examples
Elements in either Set but not in both
Equivalent to (A ∪ B) − (A ∩ B).
a = [ 1, 2, 3 ].toSet();
b = [ 3, 4, 5 ].toSet();
x = a.symmetricDifference( b );
writeOutput( x.size() );
Result: 4
Using the ^ operator shorthand
Result: 2
Related
Last updated
Was this helpful?
