ArrayEach()
call the given UDF/Closure with every value in the array.
ArrayEach( array=array, closure=function, parallel=boolean, maxThreads=number );
Returns: void
Examples
Basic Example
aNames = array("Marcus", "Sarah", "Josefine");
arrayEach(
aNames,
function(element) {
dump(element);
}
);
Parallel Example with 3 Threads
start = getTickCount();
a = ["a","b","c","d","e","f","g","h","i"];
arrayEach(
a,
function(element, index, array) {
writeOutput("<code>#index#:#element# [#getTickCount()#]</code><br>");
sleep(100);
},
true,
3
);
writeOutput('Total Time: #(getTickCount()-start)# milliseconds<br>');
See also
- Arrays
- Collections
- Threads
- array.each()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)