Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lua - Insert table values

Tags:

lua

lua-table

I got a table of form let's say:

house = {
             ["Street 22"] = {
                        {name = "George", age = 20},
                        {name = "Pete", age = 25}
                      },
             ["Street 30"] = {
                        {name = "John", age = 32},
                    }
           }

And I want to insert programmatically a third house, that is key "Street 35", with a person's details, Nick and 30 let's say. I am relatively new to lua and don't know how to do this, I must use table.insert but I am having troubles following the above format... Some help please?

like image 459
darkchampionz Avatar asked May 30 '26 12:05

darkchampionz


1 Answers

Do it simple so:

house["Street 52"] = {{name = "Nick", age = 30}}

Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!