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

setRemoveAll

Last update:
May 18, 2026
Removes from the target set all elements that appear in the source set.

Description

Bulk removes from the target set all elements that also appear in the source set. After the call, target set contains no element that was in source set (intersection with source is empty).

Returns

Void (typical).

Category

ColdFusion Set built-in functions

Function syntax

setRemoveAll(targetSet, sourceSet)

Parameters

ParameterDescription
targetSetSet to mutate.
sourceSetElements to remove from the target if present.

See also

Example

The following example uses this API in cfscript (syntax: setRemoveAll(targetSet, sourceSet)).

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

    b = setNew();
    b.add(2);
    b.add(3);

    setRemoveAll(a, b);
    writeOutput(a.size()); // 1  (only 1 left)
</cfscript>
      

Real-world example

Revoke a batch of permission codes from a user's live permission set.

 <cfscript>
    function revokeAll(required any rolePerms, required any revokedCodes) {
        setRemoveAll(rolePerms, revokedCodes);
        return rolePerms;
    }

    rolePerms = setNew();
    rolePerms.add("READ");
    rolePerms.add("WRITE");
    rolePerms.add("DELETE");

    revoked = setNew();
    revoked.add("WRITE");
    revoked.add("DELETE");

    revokeAll(rolePerms, revoked);
    writeOutput(rolePerms.has("READ")); // true
    writeOutput(rolePerms.has("WRITE")); // false
</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