Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
|
|
@ -0,0 +1,25 @@
|
|||
class Foo {
|
||||
static init() { __count = 0 } // set object counter to zero
|
||||
|
||||
construct new() {
|
||||
__count = __count + 1 // increment object counter
|
||||
_number = __count // allocates a unique number to each object created
|
||||
}
|
||||
|
||||
number { _number }
|
||||
}
|
||||
|
||||
Foo.init() // set object counter to zero
|
||||
var n = 10 // say
|
||||
// Create a List of 'n' distinct Foo objects
|
||||
var foos = List.filled(n, null)
|
||||
for (i in 0...foos.count) foos[i] = Foo.new()
|
||||
// Show they're distinct by printing out their object numbers
|
||||
foos.each { |f| System.write("%(f.number) ") }
|
||||
System.print("\n")
|
||||
|
||||
// Now create a second List where each of the 'n' elements is the same Foo object
|
||||
var foos2 = List.filled(n, Foo.new())
|
||||
// Show they're the same by printing out their object numbers
|
||||
foos2.each { |f| System.write("%(f.number) ") }
|
||||
System.print()
|
||||
Loading…
Add table
Add a link
Reference in a new issue