lua Code:
local t = {
Magic = "M",
["Poison"] = "P",
}
local dispel = "Magic"
print(t.Magic)
print(t["Magic"])
print(t[dispel])
dispel = "Poison"
print(t.Poison)
print(t["Poison"])
print(t[dispel])
The output is:
t.Magic is just syntactic sugar for
t["Magic"]. Beware
t[dispel] - it is not the same as
t["dispel"] - without the quotation marks it is the variable dispel, that contains the string value "Magic", with the quotation marks it is a string literal and thus a key named "dispel" will be looked up (which does not exist in the example)
lua Code:
local t = { "Curse" = "C" } -- INVALID SYNTAX