ArraySome()
This function calls a given closure/function with every element in a given array and returns true, if one of the closure calls returns true.
ArraySome( array=array, closure=function, parallel=boolean, maxThreads=number );
Returns: Boolean
Examples
uses a closure to determine if an item or expression exists
newArray = ['a','b','c','b','d','b','e','f'];
dump(newArray);
<span class="nv">hasSome1</span> <span class="o">=</span> <span class="nf">arraySome</span><span class="p">(</span><span class="nv">newArray</span><span class="p">,</span><span class="nf">function</span><span class="p">(</span><span class="nv">item</span><span class="p">,</span><span class="nv">idx</span><span class="p">,</span><span class="nv">arr</span><span class="p">){</span>
<span class="nv">return</span> <span class="nv">item</span> <span class="o">==</span> <span class="s1">'b'</span><span class="p">;</span>
<span class="p">});</span>
<span class="nf">dump</span><span class="p">(</span><span class="nv">hasSome1</span><span class="p">);</span>
<span class="c">// member function</span>
<span class="nv">hasSome2</span> <span class="o">=</span> <span class="nf">newArray.some</span><span class="p">(</span><span class="nf">function</span><span class="p">(</span><span class="nv">item</span><span class="p">,</span><span class="nv">idx</span><span class="p">,</span><span class="nv">arr</span><span class="p">){</span>
<span class="nv">return</span> <span class="nv">item</span> <span class="o">==</span> <span class="s1">'k'</span><span class="p">;</span>
<span class="p">});</span>
<span class="nf">dump</span><span class="p">(</span><span class="nv">hasSome2</span><span class="p">);</span>
See also
- Arrays
- Collections
- array.some()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)