Is it possible to use table.insert on nested tables?

From what I’ve tried, just doing something like
table.insert(MainTable, {[“nestedTable1”] = {}} and then
table.insert(MainTable[“nestedTable1”], {[“nestedTable2”] = {}} doesn’t work and I’m wondering if this is possible to do. There’s no errors or anything, but printing the table shows up as if I’ve just inserted them both into MainTable.

You would do it like this

MainTable["nestedTable1"] = {}
2 Likes

You can do MainTable["table1"] = {} and MainTable["table1"]["table2"] = {}

1 Like

I’ll see if these work in a few minutes, thanks for the suggestions!

table.insert() is an array exclusive function. It is not compatible with dictionaries.

2 Likes