Reputation: 91
WithLua 5.4.3, On expression [[1]], And result is '1',type is string. I can not understand, and not find any useful info on Lua document.
Upvotes: 2
Views: 108
Reputation: 2813
It is usefull if you need for example control sequences like the \n not interpreted by Lua.
Simple example...
Lua 5.3.5 Copyright (C) 1994-2018 Lua.org, PUC-Rio
> [[one]]
one
> "one"
one
> -- With \n
> [[one\n]]
one\n
> "one\n"
one
>
Upvotes: 0
Reputation: 27234
https://www.lua.org/manual/5.4/manual.html#3.1
It's introduced in section 3.1.
Literal strings can also be defined using a long format enclosed by long brackets. We define an opening long bracket of level n as an opening square bracket followed by n equal signs followed by another opening square bracket. So, an opening long bracket of level 0 is written as [[, an opening long bracket of level 1 is written as [=[, and so on.
The long format is usually used to write multiline literal strings and multiline comments.
print([===[
"Hello
world!"]===])
--[=[
"Hello
world!"
]=]
Upvotes: 4