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])

structSome 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

Lucee 4.5+ true if the items can be executed in parallel
Values:
  • true
  • false

maxThreads numeric
Default: 20

Lucee 4.5+ the maximum number of threads to use when parallel = true

Links more information about structSome

Examples sample code invoking the structSome function

Here we have simple example about structsome function.

<cfscript>
var 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>
var 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.


Fork me on GitHub