Create structure that makes it easier to find stored data.
In the [Lua][1] programming language, an array is called a table. A table is used in Lua to store data. If you're storing a lot of data in a structured way, it's useful to know your options for retrieving that data when you need it.
### Creating a table in Lua
To create a table in Lua, you instantiate the table with an arbitrary name:
There are different ways you can structure your data in a table. You could fill it with values, essentially creating a list (called a list in some languages):
Or you could create an associated array (called a map or dictionary in some languages). You can add arbitrary keys to the table using dot notation. You can also add a value to that key the same way you add a value to a variable:
If there are no keys in a table, Lua uses an index. For instance, the `mytable` table contains the values `zombie` and `apocalypse`. It contains no keys, but Lua can improvise:
You don't have to iterate over a table to get data out of it. You can call arbitrary data by either index or key:
```
print('call by index:')
print(mytable[2])
print(mytable[1])
print(myarray[2])
print(myarray[1])
print('call by key:')
print(myarray['qux'])
print(myarray['baz'])
print(mytable['surprise'])
```
The output:
```
call by index:
apocalypse
zombie
nil
nil
call by key:
halloween
happy
this value has a key
```
### Data structures
Sometimes using a Lua table makes a lot more sense than trying to keep track of dozens of individual variables. Once you understand how to structure and retrieve data in a language, you're empowered to generate complex data in an organized and safe way.