Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Key value pairs in tables

edited October 2012 in Questions Posts: 58

Can you create a table with key value pairs, such as {"name": value, "name2": value2}.
I want to be able to index a table using the key "name," rather than have to remember the numerical index of each value in the table. This works fine for a small table, but I plan on having a huge table I will need to index through, so having key value pairs would be a huge help



  • Posts: 371

    Lua is easy for this!

    tab = { myName = "Jordan" }
    print( tab["myName"] == tab.myName )
    tab2 = { ["myName"] = tab.myName }
Sign In or Register to comment.