HexLibraryHexLibrary
</> HexCodeSign inSign up
PythonJavaScriptTypeScriptCC++JavaPHPGoRustRubyBashSQLLuaPerlCOBOLPascalDelphiFortranDartSwiftC#JuliaGroovyRElixirHaskellKotlinScalaClassic ASPClipperMS-DOS
LESSONS
Introduction to LuaVariablesNumbers & MathStringsTablesConditions (if)Loops (for / while)Functions
REFERENCE
📖 Overview
🖥️ Output
📦 Variables
🔢 Numbers & Math
✍️ String
📋 Table
Table (as an array)table.insert / table.removeTable (as a dictionary)
🔁 Condition & Loop
🧩 Function
Lua›REFERENCE›Table›Table (as an array)

Table (as an array)

Ordered values (indexed from 1!).

Syntax

t = {e1, e2, e3}

Description

The only structure in Lua is the table. When used as an array, the index starts at 1. #t gives the number of elements.

Example

Loading editor…

Expected output

10
3

When to use?

Storing lists.

Common mistakes

  • ⚠️ The first element in Lua is t[1], not t[0]!

Related commands

Table (as a dictionary)table.insert / table.remove
table.insert / table.remove →
HexLibraryHexLibrary

Learn programming more clearly. Every command is explained line by line with colors, reinforced with runnable exercises, test your code instantly — all in one place, free.

Learn

  • Home
  • Languages & Lessons
  • HexCode

Company

  • About
  • Contact

Legal

  • Privacy Policy
  • Terms of Use

Other Projects

  • HexToolz
  • Free Service Manuals
© 2026 HexLibrary · The clearest way to learn code