Multiple distinct objects: Difference between revisions

(Nimrod -> Nim)
Line 608:
which is incorrect since <code>new foo</code> is only evaluated once. A correct version is:
<lang ocaml>Array.init n (fun _ -> new foo);;</lang>
 
=={{header|Oforth}}==
 
The right way : the block sent as parameter is performed n times :
{{out}}
<pre>
ListBuffer init(10, #[ Float rand ]) println
[0.281516067014556, 0.865269004241814, 0.101437334065733, 0.924166132625347, 0.88135127712
167, 0.176233635448137, 0.963837773505447, 0.570264579328023, 0.385577832707742, 0.9086026
42741616]
</pre>
 
The "wrong" way : the same value is stored n times into the list buffer
 
{{out}}
<pre>
ListBuffer initValue(10, Float rand) println
[0.314870762000671, 0.314870762000671, 0.314870762000671, 0.314870762000671, 0.31487076200
0671, 0.314870762000671, 0.314870762000671, 0.314870762000671, 0.314870762000671, 0.314870
762000671]
</pre>
 
=={{header|ooRexx}}==
1,015

edits