Whatever message this page gives is out now! Go check it out!

isDisjointFrom

Last update:
May 18, 2026
Returns true if the two sets have no elements in common.

Description

Returns a new set containing elements that are in either this set or the other set, but not in both (exclusive OR of membership: (A ∪ B) \ (A ∩ B)).

Returns

Boolean.

Category

ColdFusion Set member methods

Function syntax

set.isDisjointFrom(otherSet)

Parameters

ParameterDescription
otherSetAnother Set.

See also

Example

The following example uses this API in cfscript (syntax: set.isDisjointFrom(otherSet)).

<cfscript>
    setA = setNew();
    setA.add(1);
    setA.add(2);
    setA.add(3);

    setB = setNew();
    setB.add(2);
    setB.add(3);
    setB.add(4);

    symmetricSet = setA.symmetricDifference(setB);
    // 1 and 4 are only on one side; 2 and 3 are in both → excluded
    writeOutput(symmetricSet.size()); // 2
</cfscript>
      

Real-world example

Ensure two product bundles in a cart are mutually exclusive (no shared SKUs).

<cfscript>
    /**
    * Symmetric difference highlights IDs that appear in only one snapshot
    * (new or removed compared to pairwise “in both” sets).
    */
    yesterday = setNew();
    yesterday.add("user1");
    yesterday.add("user2");

    today = setNew();
    today.add("user2");
    today.add("user3");

    changed = yesterday.symmetricDifference(today);
    // user1 only yesterday, user3 only today
    writeOutput(changed.size()); // 2
</cfscript>
      

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page