Comments
A comment is text within a program that is not being executed. It can provide additional information to support understanding the code.
Single-line Comments
In Lua, two consecutive dashes are used to create single line comments. The compiler does not read any text after --
on the same line.
function sum(number1, number2)-- this is a commentsum = number1 + number2return sumend
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 compilerwill not run codewritten in between. ]]--
Looking to contribute?
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.