StructEach()

call the given UDF/Closure with every entry (key/value) in the struct.

StructEach( struct=struct, closure=function, parallel=boolean, maxThreads=number );

Returns: void

Argument Description Default
struct
struct, required

struct to take values from

Alias: structure

closure
function, required

A closure function (UDF) with the following signature:

function(key, value, st){}

Which is called for each item in the struct.

Alias: function, callback, udf

parallel
boolean, optional

execute closures parallel

maxThreads
number, optional

maximum number of threads executed, ignored when argument "parallel" is set to false

Alias: maxThreadCount

20

Examples

Non-Member Function

animals = {
	cow: "moo",
	pig: "oink",
	cat: "meow"
};

StructEach(animals, function(key) { // Show key 'arguments.key' Dump( label: "Key", var: arguments.key );

<span class="c">// Show key&#39;s value &#39;animals[arguments.key]&#39;</span>
<span class="nf">Dump</span><span class="p">(</span>
	<span class="nv">label</span><span class="p">:</span> <span class="nv">arguments.key</span> <span class="o">&amp;</span> <span class="s2">&quot;&#39;s value&quot;</span><span class="p">,</span>
	<span class="k">var</span><span class="p">:</span> <span class="nv">animals</span><span class="p">[</span><span class="nv">arguments.key</span><span class="p">]</span>
<span class="p">);</span>

});

See also