Spec-Zone.ru › ColdFusion

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

  • CF2018.0.5+
  • Lucee
  • BL 1.0.0+
  • See Also: structEach structMap structReduce structFilter

    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

    • 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

    The simple StructSome example

    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.

    The structSome member function example

    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

    Spec-Zone.ru

    Настройки Оффлайн Что нового Помощь О нас
    Spec-Zone .ru
    спецификации, руководства, описания, API