I'm trying to find out a way to use a multiline comment on a batch of code, but it keeps mistaking some syntax in it as a ]] and thinking I want it to end there, which I don't!
--[[ for k,v in pairs(t) do local d = fullToShort[k] local col = xColours[v[1]] -- It stops here! cecho(string.format(("<%s>%s ", col, d)) end --]]
I thought I read somewhere it was possible to do use a different sort of combination to avoid those errors, like --[=[ or whatnot... Could someone help?
A comment starts with a double hyphen ( -- ) anywhere outside a string. They run until the end of the line. You can comment out a full block of code by surrounding it with --[[ and --]] . To uncomment the same block, simply add another hyphen to the first enclosure, as in ---[[ .
Using triple-quoted string literals Another way to add multiline comments is to use triple-quoted, multi-line strings. These strings are to be used carefully and should not be confused with Docstrings (triple-quoted string literals appearing right after a function/class/module to generate documentation).
Multiline Comments You can comment multiple lines by the special beginning tag <! -- and ending tag --> placed before the first line and end of the last line as shown in the given example below.
Hash character(#) is used to comment the line in the Python program. Comments does not have to be text to explain the code, it can also be used to prevent Python from executing code. The hash character should be placed before the line to be commented.
As you can see in Strings tutorial there is a special [===[
syntax for nesting square braces. You can use it in block comments too. Just note, that number of =
signs must be the same in open and close sequence.
For example 5 equals will work.
--[=====[ for k,v in pairs(t) do local d = fullToShort[k] local col = xColours[v[1]] -- It stops here! cecho(string.format(("<%s>%s ", col, d)) end --]=====]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With