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

  • 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)
主站蜘蛛池模板: 嵊泗县| 靖宇县| 东方市| 沅江市| 毕节市| 和平区| 读书| 阳西县| 奈曼旗| 米易县| 卫辉市| 佛坪县| 丹阳市| 曲水县| 交城县| 昭苏县| 禄劝| 绥德县| 塘沽区| 西乌| 玉田县| 买车| 洪泽县| 三明市| 班玛县| 额尔古纳市| 乐东| 武邑县| 西乌| 成都市| 博爱县| 鄂伦春自治旗| 龙川县| 汤原县| 务川| 凭祥市| 罗田县| 岳普湖县| 竹山县| 永平县| 西峡县|