View Single Post
03-05-13, 12:22 AM   #11
Phanx
Cat.
 
Phanx's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2006
Posts: 5,617
Yes, but your syntax is bad, Xin. You must be rusty from all that time away!

This works:
Code:
local tbl = {
    ["Phanx"] = 1,
    ["Clamsoda"] = 1,
    ["Seerah"] = 1,
    ["Dridzt"] = 1,
    ["Haleth"] = 1,
}
And this works, for strings containing only letters, numbers, and underscores:
Code:
local tbl = {
    Phanx = 1,
    Clamsoda = 1,
    Seerah = 1,
    Dridzt = 1,
    Haleth = 1,
}
But this will raise an error, because you can't use strings that way:
Code:
local tbl = {
    "Phanx" = 1,
    "Clamsoda" = 1,
    "Seerah" = 1,
    "Dridzt" = 1,
    "Haleth" = 1,
}
On a side note, please never, ever name your table "table" -- that's already a global defined by WoW Lua, and is a table containing table-related functions, like table.insert, table.remove, table.sort, etc. More generally, you should never give anything the same name (even if it's local) as a global Lua function/object or a global WoW API function (eg. UnitName) or a global WoW UI object (eg. ChatFrame1). If your variable gets leaked into the global namespace, you will break other addons and/or the Blizzard UI and/or the UI in general. Even if it stays local, it's still just creating unnecessary confusion -- when you look at a part of your code using the variable, you have to figure out whether that code is referring to your local thing or the global thing with the same name -- and is a bad habit to be in.
__________________
Retired author of too many addons.
Message me if you're interested in taking over one of my addons.
Don’t message me about addon bugs or programming questions.
  Reply With Quote