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

applyToEither (Future method)

Last update:
May 18, 2026
When either future completes successfully first, transforms the winning value on the completing thread.

Description

Synchronous counterpart to applyToEitherAsync.

Returns

A new Future.

Category

Asynchronous programming

Function syntax

future.applyToEither(other, function)

Parameters

ParameterDescription
otherRequired. The other Future to race.
functionRequired. A function that takes the first completed value and returns a transformed value.

See also

Example

From product tests.

<cfscript>
    f1 = runAsync(function() { return "fast"; });
    f2 = runAsync(function() {    sleep(1000);    return "slow";});
    either = f1.applyToEither(f2, function(x) {    return x & "_processed";});
    writeOutput(either.get()); // fast_processed
</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