I have the following code:
local ta = { nil, nil, nil, 1, a = 2 }
local tb = { [4] = 1, a = 2 }
for i = 1,
print('ta['..i..']= ', ta[i])
end
for i = 1,
print('tb['..i..']= ', tb[i])
end
And get the following result:
ta[1]= nil
ta[2]= nil
ta[3]= nil
ta[4]= 1
I suggested that both tables should be the same. But it’s not really.
I am trying to create a table with an empty constructor and initialize the elements one by one, including nils at the beginning. But I got the same result with the tb table.
Who cares? Can I manage it manually?
source
share