So I was experimenting with table.create
and I am a little bit confused as to what’s happening here:
local myTable = table.create(4,{})
for i = 1, #myTable do
print(myTable[i])
myTable[i][1] = "string"
end
If I understand this correctly, it should print out something like this:
19:48:32.483 {} - Server - Test:4
19:48:32.483 {} - Server - Test:4
19:48:32.484 {} - Server - Test:4
19:48:32.484 {} - Server - Test:4
But instead, I got this:
19:50:46.553 {} - Server - Test:4
19:50:46.553 ▼ {
[1] = "string"
} - Server - Test:4
19:50:46.554 ▼ {
[1] = "string"
} - Server - Test:4
19:50:46.554 ▼ {
[1] = "string"
} - Server - Test:4
I then changed the first line of code to this:
local myTable = {{},{},{},{}}
and it seems to be working as expected.
I tried looking at the documentation for table.create
to find out what’s happening but I can’t seem to find the issue.
Does anyone know what’s happening here?