Unless you have a specific reason to use an indexed table, it would be more efficient to use a "dictionary style" table with key/value pairs:
Code:
local t = { ["a"] = true, ["b"] = true, ["c"] = true, }
Then, instead of interating over the whole table, you can just do:
Code:
local v = "a"
if t[v] then print("Found!") else print("Not found.") end
Result: the value is in the table, so "Found!" is output.
Code:
local v = "x"
if t[v] then print("Found!") else print("Not found.") end
Result: the value is not in the table, so "Not found." is output.
Edit:
You don't necessarily need to use the boolean
true as your value, but it's the simplest way to go if the only thing you're going to use the table for is checking "is this value in this table?".