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

setSome

Last update:
Jun 9, 2026
Returns true if callback(item) is true for at least one element.

Description

Determines if at least one element in the array satisfies a given condition.

Returns

True if at least one element matches a condition; false, otherwise.

Category

ColdFusion Set helper utilities

Function syntax

setSome(set, callback)

Parameters

ParameterDescription
setSet to test.
callbackFunction to encapsulate the criteria.

See also

Example

The following example uses this API in cfscript (syntax: utils.setSome(set, callback)).

<cfscript>
    s = setNew();
    s.add(1);
    s.add(2);
    s.add(3);
    s.add(4);
    s.add(5);

    isEven=(x)=>return x%2==0
    writeOutput(setSome(s,isEven)) // Returns TRUE
</cfscript>
      

Real-world example

Check whether any role equals ADMIN.

<cfscript>
    roles = setNew();
    roles.add("READ");
    roles.add("WRITE");
    roles.add("BILLING");

    hasAdmin = setSome(roles, function (role) {
        return trim(uCase(role)) == "ADMIN";
    });

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