Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What do the equals signs mean in multiple line comments? (see desc for details)

Asked by 6 years ago

I was wondering if anyone could explain to me what the equals signs mean in multiple line comments. eg. --[==[. I have looked on the roblox site however am confused with the term ‘levels’.

2
that is used in if statements eg if game.Workspace.Gravity == 0 then, its not used anywhere else Gameplayer365247v2 1055 — 6y

1 answer

Log in to vote
0
Answered by
Rheines 661 Moderation Voter
6 years ago
Edited 6 years ago

When we usually end a multi-line comment using ]], we can accidentally end the comment (such as commenting out code that makes use of tables or dictionaries.)

Here is an example:

01local list = {'a','b','c'}
02local example = {a = 1, b = 2, c = 3}
03--[[
04while true do
05    local var = example[list[1]] --The comment ends here.
06    print(var)
07    wait()
08end
09]]
10print(true)

When we run this, we get an error: unexpected symbol near ']'

To leverage this situation, we can add an equal sign in the front and back (or more) to define a new delimiter to end the comment. The catch is that it needs to be have equal amount of signs in the beginning at the end.

01local list = {'a','b','c'}
02 
03local example = {a = 1, b = 2, c = 3}
04 
05--[==[
06while true do
07    local var = example[list[1]]
08    print(var)
09    wait()
10end
11]==] --Comment ends here now.
12 
13print(true)

When we run this, it prints as expected: true

If this answers your question, please accept this as the solution.

0
Thanks. Just what I was looking for. :) Sir_funnyguy 4 — 6y
Ad

Answer this question