StructEvery()
This function calls a given closure/function with every element in a given struct and returns true, if all of the closure calls returns true.
StructEvery( struct=struct, closure=function, parallel=boolean, maxThreads=number );
Returns: Boolean
Examples
Non-Member Function
animals = {
cow: "moo",
pig: "oink",
cat: "meow"
};
// Use StructEvery() to iterate over keys in struct. Closure returns true/false.
allAnimalsAreNoisy = StructEvery(animals, function(key) {
// If the key has a value return true (noisy animal)
if (Len(animals[arguments.key])) {
return true;
}
<span class="nv">return</span> <span class="nv">false</span><span class="p">;</span>
});
Dump(
label: "allAnimalsAreNoisy",
var: allAnimalsAreNoisy
);
// Use StructEvery() to iterate over keys in struct. Closure returns true/false.
allAnimalsAreQuiet = StructEvery(animals, function(key) {
// If the key is blank return true (quiet animal)
if (! Len(animals[arguments.key])) {
return true;
}
<span class="nv">return</span> <span class="nv">false</span><span class="p">;</span>
});
Dump(
label: "allAnimalsAreQuiet",
var: allAnimalsAreQuiet
);
See also
- Collections
- Structures
- Threads
- struct.every()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)