structSome
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
Member Function Syntax
struct.some(function(key, value [,struct]){} [, parallel] [, maxThreads])
Argument Reference
struct struct Required
callback boolean Required
Closure or a function reference that will be called for each of the iteration.
Callback parameters:
-
key* string : The key for the current iteration -
value* any : The value for the current iteration -
struct* struct : A reference of the original struct
parallel boolean
Default: false
false
Lucee 4.5+ true if the items can be executed in parallel
Values:
truefalse
maxThreads numeric
Default: 20
20
Lucee 4.5+ the maximum number of threads to use when parallel = true
Links more information about structSome
- Map, Reduce and other Higher Order Functions - A Primer for map, reduce, filter, and Higher Order Functions in general.
Examples Sample code invoking the structSome function
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> Expected Result: Key Exists.
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> Expected Result: No Key Exists.
© 2012–present Foundeo, Inc. and the CFDocs contributors.
Licensed under the MIT License.
ColdFusion is a trademark of Adobe Systems Incorporated.
https://cfdocs.org/structsome