lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


1. Why does this not work?

a = { 1, 2, 3, 4 } [1] --> Error: unexpected symbol near '['


But this does:


a = ({ 1, 2, 3, 4 }) [1]

print (a)  --> 1



2. Similarly:

s = "testing" : upper () --> Error: ')' expected near ':'


But:

s = ("testing") : upper ()
print (s) --> TESTING

Putting brackets around a literal string, or a table constructor seems to somehow "finalize" their construction, so they can be used normally afterwards, but what is the precise reason for their requirement?