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

delete

Last update:
May 18, 2026
Removes an element from the set if present.

Description

Removes an element from the set if it is present. If the element is not present, there's no exception.

Returns

Void

Category

ColdFusion Set member methods

Function syntax

set.delete(element)

Parameters

ParameterDescription
elementElement to remove.

See also

Example

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

<cfscript>
    s = setNew();
    s.add("a");
    s.delete("a");
    s.delete("b"); // no error if not found
    writeOutput(s.isEmpty()); // true
</cfscript>      
      

Real-world example

Remove a completed job ID from an in-memory pending set after success.

<cfscript>
    // Application or request scope: jobs not yet finished
    pendingJobIds = setNew();

    function queueJob(required string jobId) {
        pendingJobIds.add(jobId);
    }

    function onJobSucceeded(required string jobId) {
        // Worker finished OK — no longer pending
        pendingJobIds.delete(jobId);
    }

    function isJobStillPending(required string jobId) {
        return pendingJobIds.has(jobId);
    }

    // Example flow
    queueJob("job-export-2025-04-01-001");
    queueJob("job-export-2025-04-01-002");
    writeOutput(pendingJobIds.size()); // 2

    onJobSucceeded("job-export-2025-04-01-001");
    writeOutput(pendingJobIds.size()); // 1
    writeOutput(isJobStillPending("job-export-2025-04-01-001")); // false
    writeOutput(isJobStillPending("job-export-2025-04-01-002")); // true
</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