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

size

Last update:
May 18, 2026
Returns the number of distinct elements in the set.

Description

Cardinality of the set. count may be an alias of size (verify in release documentation).

Returns

Numeric.

Category

ColdFusion Set member methods

Function syntax

set.size()
set.count()

Parameters

ParameterDescription
None.

See also

Example

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

<cfscript>
    s = setNew();
    writeOutput(s.size()); // 0

    s.add("a");
    s.add("b");
    writeOutput(s.size()); // 2
</cfscript>
      

Real-world example

Dashboard KPI: count distinct customers who placed an order in the set.

<cfscript>
    function uniqueCustomerCount(required any orderIdSet) {
        return orderIdSet.size();
    }

    ids = setNew();
    ids.add(1001);
    ids.add(1002);
    ids.add(1001); // duplicate

    writeOutput(uniqueCustomerCount(ids)); // 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