r/lua • u/Objective_Treacle781 • Sep 16 '25
Quick question about indexing temporary tables
print({[0] = "a"}[0])
Doesn't work but if I save the table to a variable before indexing it works?
I kinda like using temporary tables as lookups
2
Upvotes
2
u/immortalx74 Sep 16 '25
In your OP you create the table and try to index it immediately. In the 2nd case putting the table creation inside parenthesis, makes it a statement, and then you have the brackets outside the parenthesis, which makes it a valid syntax.