Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
|
|
@ -0,0 +1,32 @@
|
|||
local foo_count = 0
|
||||
|
||||
class foo
|
||||
private number
|
||||
|
||||
function __construct()
|
||||
foo_count += 1 -- increment object counter
|
||||
self.number = foo_count -- allocates a unique number to each object created
|
||||
end
|
||||
|
||||
function getNumber() return self.number end
|
||||
end
|
||||
|
||||
local n = 10 -- say
|
||||
-- Create a List of 'n' distinct foo objects
|
||||
local foos = table.create(n)
|
||||
for i = 1, n do foos[i] = new foo() end
|
||||
-- Show they're distinct by printing out their object numbers
|
||||
foos:foreach(|f|-> do
|
||||
io.write($"{f:getNumber()} ")
|
||||
end)
|
||||
print("\n")
|
||||
|
||||
-- Now create a second List where each of the 'n' elements is the same foo object
|
||||
local foos2 = table.create(n)
|
||||
local foo = new foo()
|
||||
for i = 1, n do foos2[i] = foo end
|
||||
-- Show they're the same by printing out their object numbers.
|
||||
foos2:foreach(|f| -> do
|
||||
io.write($"{f:getNumber()} ")
|
||||
end)
|
||||
print()
|
||||
Loading…
Add table
Add a link
Reference in a new issue