Checco2212, on 17 June 2016 - 10:02 AM, said:
--snip--
I don't understand why I need these brackets, usually I don't use them...
Ok, so this is not really necessary but I'm going to try to explain why you
need to have either quotes
and brackets, or neither, and in some cases you don't have a choice.
Brackets (when defining a table('s key)) specify that your going to input an exact, constant data type. A literal, if you will. This can be in the form of primitives, such as numbers or strings, or you can pass variables that contain more complex data types such as functions, or even other tables. When you do
not have brackets, it assumes that your going to pass it a plain sequence of characters consisting of only characters or characters with numbers, it's basically a shortcut of using brackets and enclosing them with quotes, so, when you include quotes when trying to assign a key, it sees a quote and assumes that you're trying to set a value of an automatically numerically indexed table. So when it sees the equals sign it freaks out, because it thought that you were trying to assign a value, something that is succeeded by a comma to indicate the next entry in the table, and it errors. When you need the key to have special characters such as quotes, commas, spaces, etc. you don't have a choice, because you can't supply them without quotes and brackets because the interpreter will get confused, so you can use a literal string (and use escapes if you need to have quotes as part of your key) to define an entry.
Hope I helped.