官术网_书友最值得收藏!

  • Lua Quick Start Guide
  • Gabor Szauer
  • 133字
  • 2021-08-05 10:30:38

Concatenate strings

Two strings can be concatenated by placing a .. symbol between them. It is very important to have at least one space on both the left and right of the .. symbol. Concatenating two strings results in a new string, which can be stored in a variable or used in its place. Any combination of variables and literals can be concatenated, as the following code demonstrates:

name = "Mike"
color = "Blue"
-- Concatenate three strings
print ("Jill " .. "likes" .. " Red")
-- Concatenate a variable and a strings
print ("Jack dislikes " .. color)
-- Concatenate two variables and a string
print (name .. " likes " .. color)
-- Concatenate only variables
print (name .. color)
-- Assign result to variable
message = name .. " likes " .. color
print (message)
主站蜘蛛池模板: 长垣县| 宁城县| 靖远县| 宝丰县| 溧阳市| 股票| 安康市| 五家渠市| 崇礼县| 格尔木市| 饶阳县| 鄂托克旗| 遵义市| 莱阳市| 金昌市| 观塘区| 开化县| 全州县| 肇州县| 长白| 蚌埠市| 蒙山县| 色达县| 云和县| 灌云县| 蕉岭县| 安塞县| 兰西县| 汕头市| 措勤县| 克什克腾旗| 贡觉县| 堆龙德庆县| 黔西县| 静海县| 太仆寺旗| 临漳县| 饶阳县| 太谷县| 榆社县| 巫山县|