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

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)
主站蜘蛛池模板: 巴里| 道真| 洪泽县| 迁西县| 浦江县| 灯塔市| 南京市| 绥德县| 澄迈县| 唐河县| 娄底市| 黎平县| 湘潭市| 淅川县| 连南| 江陵县| 肇源县| 平山县| 广安市| 泸西县| 衡东县| 西畴县| 古田县| 平乐县| 富蕴县| 沭阳县| 潼关县| 泗阳县| 繁昌县| 华蓥市| 剑河县| 长武县| 邢台市| 建湖县| 武安市| 札达县| 芒康县| 金塔县| 临桂县| 英山县| 蓬莱市|