Urb*_*ley 7 lua string-concatenation
我试图将变量连接成一个纯文字字符串,纯粹是出于可读性的目的,例如
myString = "test"
myString2 = [[
first part of the string
this is a " .. myString .. " string
last part of the string]]
print(myString2)
Run Code Online (Sandbox Code Playgroud)
但这确实是输出
first part of the string
this is a " .. myString .. " string
last part of the string
Run Code Online (Sandbox Code Playgroud)
我确信它很简单,但我已经尝试使用谷歌搜索来了解如何实现这一点,并且空白了.
atl*_*ist 11
双括号分隔符内的引号没有做任何事情.结束双支架的唯一方法是使用双支架:
myString2 = [[
first part of the string
this is a ]] .. myString .. [[ string
last part of the string]]
Run Code Online (Sandbox Code Playgroud)
那会给你:
first part of the string
this is a test string
last part of the string
Run Code Online (Sandbox Code Playgroud)
见:http://www.lua.org/pil/2.4.html