arraySome

Calls a given closure/function with every element in a given array and returns true if one of the closure calls returns true

arraySome(array, function(item [,index, array]){} [, parallel] [, maxThreads]) → returns boolean

Member Function Syntax

someArray.some(function(item [,index, array]){} [, parallel] [, maxThreads])

This function requires Lucee.  Not supported on Adobe ColdFusion, etc.

arraySome Argument Reference

array array
Required

Array to iterate

callback boolean
Required

Closure or a function reference that will be called for each of the iteration.

Callback parameters:

  • value*any : The value for the current iteration
  • index*numeric : The current index for the iteration
  • array*array : A reference of the original array

parallel boolean

Execute closures parallel

maxThreads numeric
Default: 20

Maximum number of threads executed, ignored when argument "parallel" is set to false

Links more information about arraySome

Examples sample code invoking the arraySome function

// Create an array
arrayList = ["apple", "pineapple", "mango", "apricot"];

// Match some
result = arraySome(arrayList, function(fruit) {
    return fruit.startsWith("a");
});

// Print result
writeOutput((result ? "Some" : "No") & " matches  were found!");

Expected Result: Some matches were found!

// Create an array
arrayList = ["apple", "pineapple", "mango", "apricot"];

// Match some
result = arrayList.some(function(fruit) {
    return fruit.endsWith("a");
});

// Print result
writeOutput((result ? "Some" : "No") & " matches  were found!");

Expected Result: No matches were found!


Fork me on GitHub