Lua is different from other languages in that it unifies dictionaries and arrays.
In many languages, there is an object called a dictionary. It’s a set with each member identifiable by (usually) a string. So with a dictionary, you do things like:
[lua]
myDict.this = 50
– or –
myDict[“this”] = 50
[/lua]
Just about every language also has a set called an array. They’re much like dictionaries, but they use numbers instead of strings. Like so:
[lua]
myArray[1] = 5
[/lua]
This is where Lua is different. Lua creates one data storage object, called a table, that can store things under any index type. So with Lua, you can use tables as keys, booleans as keys, even functions as keys - in addition to numbers and strings.
When indexing a table through [key], it will return whatever is stored under that key. Each key is unique - numbers, strings, functions, booleans, threads, userdata, table, what-have-you. Declaring a table without naming keys - {“a”, “b”, “c”} - turns into {[1] = “a”, [2] = “b”, [3] = “c”}. Thus, they’re not the same.