Table.insert with string index

Hi so let’s say I have a table:

local data = {
			["Things"] = nil,
		}

And I want to insert multiple values into the [“Things”] index.

with Table.insert you can’t do this as far as i know, and doing data[“Things”] = value doesn’t work because then i can’t insert multiple.

How would i do this?

You can make data.Things a nested table.

local data = {}
data.Things = {} --> new table at key "Things" (alternatively data["Things"] = {})
print(data.Things) --> {}
table.insert(data.Things, "a") --> insert "a" at index 1 into Things
print(data.Things[1]) --> "a"

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.