Multiple distinct objects: Difference between revisions

m
m (syntax highlighting fixup automation)
imported>Arakov
 
(2 intermediate revisions by 2 users not shown)
Line 478:
// create a list of disting object
fill(n)
= RangeEnumerator.new(1,n).selectBy::(x => new Foo()).toArray();
 
// testing
Line 1,325:
say words(randoms) ' unique numbers generated.' /*stick a fork in it, we're all done. */</syntaxhighlight>
<br><br>
 
=={{header|RPL}}==
{{works with|HP|49}}
To create a list of n references to the same object:
<span style="color:blue">FOO</span> n DUPN →LIST
To create a list of n distinct objects:
« <span style="color:blue">FOO</span> » 'X' 1 n 1 SEQ
The FOO function can access the rank at which the object will be stored by reading the X variable.
 
=={{header|Ruby}}==
Line 1,467 ⟶ 1,475:
 
=={{header|Wren}}==
<syntaxhighlight lang="ecmascriptwren">class Foo {
static init() { __count = 0 } // set object counter to zero
 
Anonymous user