ArraySome()
This function 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=array, closure=function, parallel=boolean, maxThreads=number );
Returns: Boolean
| Argument | Description | Default |
|---|---|---|
|
array
array,
required
|
edit
array to iterate Alias: object |
|
|
closure
function,
required
|
edit
function/closure that implements the following constructor [function(any value[, numeric index,array array]):boolean]. Alias: function, callback, udf |
|
|
parallel
boolean,
optional
|
edit
execute closures parallel |
|
|
maxThreads
number,
optional
|
edit
maximum number of threads executed, ignored when argument "parallel" is set to false Alias: maxThreadCount |
20 |
Examples
edituses a closure to determine if an item or expression exists
newArray = ['a','b','c','b','d','b','e','f'];
dump(newArray);
hasSome1 = arraySome(newArray,function(item,idx,arr){
return item == 'b';
});
dump(hasSome1);
// member function
hasSome2 = newArray.some(function(item,idx,arr){
return item == 'k';
});
dump(hasSome2);
See also
- Arrays
- Collections
- array.some()
- Search Issue Tracker open_in_new
- Search Lucee Test Cases open_in_new (good for further, detailed examples)