Menu
Coddy logo textTech

What is a Table?

Part of the Fundamentals section of Coddy's Lua journey — lesson 56 of 90.

The table. Tables are Lua's single built-in data structure, but don't let that simplicity fool you - they're incredibly powerful and versatile.

Think of a table as a container that can hold multiple pieces of information. Unlike the simple variables you've worked with so far (which store just one value), a table can store many values in an organized way.

Tables can be used in different ways depending on what you need. In this chapter, we'll focus on using tables as lists - ordered collections of items where you can store things like a shopping list, player scores, or inventory items.

-- A simple list of player names
players = {"Alice", "Bob", "Charlie"}

-- A list of scores
scores = {100, 85, 92, 78}

Cheat sheet

Tables are Lua's single built-in data structure that can hold multiple pieces of information. They can be used as lists - ordered collections of items.

Create a table using curly braces {} with comma-separated values:

-- A simple list of player names
players = {"Alice", "Bob", "Charlie"}

-- A list of scores
scores = {100, 85, 92, 78}

Try it yourself

This lesson doesn't include a code challenge.

quiz iconTest yourself

This lesson includes a short quiz. Start the lesson to answer it and track your progress.

All lessons in Fundamentals