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

setAddAll

Last update:
May 18, 2026
Adds all elements from the source set into the target set.

Description

Bulk adds all elements from one set to another. The target set grows to include evey element from the source set. Duplicates are ignored.

Returns

Void

Category

ColdFusion Set built-in functions

Function syntax

setAddAll(targetSet, sourceSet)

Parameters

ParameterDescription
targetSetSet to mutate.
sourceSetElements to add.

See also

Example

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

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

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

    setAddAll(a, b);
    writeOutput(a.size()); // 3
</cfscript>
      

Real-world example

Merge IDs from multiple query batches into one accumulator set for pagination.


<cfscript>
    function accumulateIds(required any accumulator, required any batch) {
        setAddAll(accumulator, batch);
        return accumulator;
    }

    all = setNew();
    batch1 = setNew();
    batch1.add("id-100");
    batch1.add("id-200");

    batch2 = setNew();
    batch2.add("id-200"); // duplicate across batches
    batch2.add("id-300");

    accumulateIds(all, batch1);
    accumulateIds(all, batch2);
    writeOutput(all.size()); // 3
</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