Lua Comments

findlang's avatar
Published Aug 4, 2023Updated Jan 19, 2025
Contribute to Docs

A comment is text within a program that is not being executed. It can provide additional information to help understand the code.

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours

Single-line Comments

In Lua, two consecutive dashes are used to create single-line comments. The compiler reads no text after -- on the same line.

function sum(number1, number2)
-- this is a comment
sum = number1 + number2
return sum
end

The comment does not affect the function.

Multi-line Comments

In Lua, multi-line comments are created using the --[[ syntax to start the comment and ]] to end the comment. The compiler does not read any text in between.

--[[ this is a multi-line comment.
The compiler
will not run code
written in between.
]]

All contributors

Contribute to Docs

Learn Lua on Codecademy

  • Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
    • Includes 6 Courses
    • With Professional Certification
    • Beginner Friendly.
      75 hours
  • Learn the basics of Lua, a general-purpose programming language used for building games, web apps, and developer tools.
    • Beginner Friendly.
      4 hours