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

intersection

Last update:
May 18, 2026
Returns the intersection of this set and another set.

Description

Returns the intersection of two sets. The output is only elements present in both sets.

Returns

A new Set.

Category

ColdFusion Set member methods

Function syntax

set.intersection(otherSet)

Parameters

ParameterDescription
otherSetAnother Set.

See also

Example

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

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

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

    intersectionSet = setA.intersection(setB);
    writeOutput(intersectionSet.size()); // 2  (2 and 3)
</cfscript>
      

Real-world example

Screen candidates: required job skills intersect candidate skills.

<cfscript>
    requiredSkills = setNew();
    requiredSkills.add("SQL");
    requiredSkills.add("CFML");
    requiredSkills.add("REST");

    candidateSkills = setNew();
    candidateSkills.add("CFML");
    candidateSkills.add("HTML");
    candidateSkills.add("SQL");

    matched = requiredSkills.intersection(candidateSkills);
    writeOutput(matched.size()); // 2 — overlap for screening
</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