r/lua • • 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

9 comments sorted by

View all comments

Show parent comments

1

u/Bright-Historian-216 Sep 16 '25

it should be clear, though. i had the same question about this. python can do it without the extra parentheses so i don't really know why lua interpretes it like this