local tab = {} local key = "Potatoes" local value = "are cool" tab[key] = value -- or you could do: tab.Potatoes = "are cool" -- or tab["Potatoes"] = "are cool" print(tab[key]) -- prints: are cool print(tab.Potatoes) -- prints: are cool print(tab["Potatoes"]) -- prints: are cool for key, value in pairs(tab) do print(key, value) end -- since we have a "Potatoes" key with "are cool" as its value, it would print: -- Potatoes are cool
on line 6 it saids tab[key] = value
but i dont understand what this does
Its like inserting but I dont understand how this inserts
shoudl't doing this change tabs key into value which is 'are cool'
but it dosen't it prints Potatoes are cool and merges it
This is because it adds an index to the table, it sets the index to the table