This function calls a given closure/function with every element in a given struct and returns true, if one of the closure calls returns true
structSome(struct, function(key, value [,struct]){} [, parallel] [, maxThreads])
returns boolean
struct.some(function(key, value [,struct]){} [, parallel] [, maxThreads])
Name | Type | Required | Default | Description |
---|---|---|---|---|
struct | struct | Yes | ||
callback | boolean | Yes | Closure or a function reference that will be called for each of the iteration. | |
parallel | boolean | No | false | Lucee4.5+ true if the items can be executed in parallel |
maxThreads | numeric | No | 20 | Lucee4.5+ the maximum number of threads to use when parallel = true |
| Name | Type | Required | Description | | — | — | — | — | | key | string | No | The key for the current iteration | value | any | No | The value for the current iteration | struct | struct | No | A reference of the original struct
Here we have simple example about structsome function.
<cfscript>
struct={"Name":"Raja","age":20,"mark":80};
result = structSome(struct,function(key,value){
return key IS "Name"
});
writeOutput((result ? '' : 'No')& " Key Exists.")
</cfscript>
Here we have simple example about structsome as member function.
<cfscript>
struct={"Name":"Raja","age":20,"mark":80};
result = struct.some(function(key,value){
return key IS "average"
});
writeOutput((result ? '' : 'No')&" Key Exists.")
</cfscript>