Multiple distinct objects: Difference between revisions

m
Line 612:
 
The right way : the block sent as parameter is performed n times :
 
<lang Oforth>ListBuffer init(10, #[ Float rand ]) println</lang>
 
{{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
Line 621 ⟶ 623:
 
The "wrong" way : the same value is stored n times into the list buffer
 
<lang Oforth>ListBuffer initValue(10, Float rand) println</lang>
 
{{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
1,015

edits