local tbl = {}
local tbl2 = {}

tbl[tbl2] = {position = 12}
tbl.tb2.position = 12

--Difference between those 2 on line 4 and 5?

4 comments

0

Both of these are wrong. The first one tries to use a table as a key, which you can't do. The second one tries to index "position" of a nil value.

0

Tb2 doesn’t exist, not would correcting it to tbl2. It would need to be created vis table.insert() or initiated in tbl’s creation. This counts for position too.

0

Although you can use an array as an index, it is v e r y not recommended.

0

I don't really have a good understanding of how lua indexes work. So like if I had a foo variable with a value of 4 inside of a table, is the foo an index for the value of 4?