How do I escape in a double-bracket multi-line string?

--[[
Just a dumb question,
but how do I escape in
a double-bracket?
(It's a haiku btw but you get my question.)

Anyways, being serious, there was only a few posts about the [[]] thing,
and I'm not talking about comments (like this). I was wondering if there was a
solution to the use of something like {} or .., and I kind of got nowhere.

Is there a solution to this:
]]
local str = [[
{This does not work}, and neither]] .. '' .. [[
this (it breaks the line for absolutely no reason and looks horrible to be a solution)
Am I just dumb or something? Let me know any solutions.]]

Actually, I found a solution, but I don’t know if there’s a better (and more readable) solution out there:

print([[Lorem ipsum,
]]..workspace.DistributedGameTime..[[

dolor sit amet,]])
--[[Returns:
Lorem ipsum,
0
dolor sit amet,]]
print(("Lorem ipsum,\n%s\n\ndolor sit amet,"):format(workspace.DistributedGameTime))

local str = ([=[Lorem ipsum,%s dolor sit amet,
]=]):format(workspace.DistributedGameTime)

Idk, yours looks just as good as them..

Mmm, I guess it’s just the limitations of Luau then. I’ll mark mine as solution in that case. Thanks for your input, though!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.