StructSome(struct,callback)
structObj.Some(callback)
Parameter |
Required/Optional |
Description |
struct |
Required |
Struct in which at least one value is to be searched. |
callback |
Required |
Function that encapsulates the criteria. |
<cfscript> mystruct = {a=1,b=2,c=3}; doesValExist=(key,value,struct)=>return value==1 writeoutput(structSome(mystruct,doesValExist)) </cfscript>
<cfscript> structEven={a=2,b=4,c=8,d=10,e=12} isEven=(key,value)=>value%2==0 writeOutput(StructSome(structEven,isEven)) // Returns True </cfscript>
<cfscript> structEven={a=2,b=4,c=8,d=10,e=12} isEven=(key,value)=>return value%2==0 writeOutput(structEven.Some(isEven)) // Returns True </cfscript>
<cfscript> ordstruct=["key1":"abc","key2":"def","key3":"sss"] lambdaFunc= key => key.contains("key") writeOutput(ordstruct.Some(lambdaFunc)) </cfscript>
<cfscript> mystruct={"key1":"aval","key2":"bval","key3":"cval"} result=StructSome(struct=mystruct,callback=function(key,val){ if (key.contains("key1") && val.startswith("a")) return 1 else return 0 } ) writeOutput(result) </cfscript>