StructMap()
Calls the given closure with every element in the given struct. the function returns a struct that contains all values returned by the closure.
StructMap( struct=struct, closure=function, parallel=boolean, maxThreads=number );
Returns: Struct
Examples
structmap examples
sct=structNew("linked");
sct.a=1;
sct.b=2;
sct.c=3;
writedump(var=sct, label="original struct");
<span class="c">// base test</span>
<span class="nv">res</span><span class="o">=</span><span class="nf">StructMap</span><span class="p">(</span><span class="nv">sct</span><span class="p">,</span> <span class="nf">function</span><span class="p">(</span><span class="nv">key</span><span class="p">,</span> <span class="nv">value</span> <span class="p">){</span>
<span class="nv">return</span> <span class="nv">key</span><span class="o">&</span><span class="s2">":"</span><span class="o">&</span><span class="nv">value</span><span class="p">;</span>
<span class="p">},</span><span class="nv">true</span><span class="p">);</span>
<span class="nf">writedump</span><span class="p">(</span><span class="k">var</span><span class="o">=</span><span class="nv">res</span><span class="p">,</span> <span class="nv">label</span><span class="o">=</span><span class="s2">"mapped struct"</span><span class="p">);</span>
See also
- Collections
- Structures
- Threads
- struct.map()
- Search Issue Tracker
- Search Lucee Test Cases (good for further, detailed examples)