- 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)
推薦閱讀
- Vue.js設計與實現
- Fundamentals of Linux
- Objective-C Memory Management Essentials
- Manga Studio Ex 5 Cookbook
- SQL Server 2012數據庫技術及應用(微課版·第5版)
- Android 7編程入門經典:使用Android Studio 2(第4版)
- Spring Cloud、Nginx高并發核心編程
- The Data Visualization Workshop
- Java程序設計
- Symfony2 Essentials
- RealSenseTM互動開發實戰
- Building Serverless Web Applications
- MINECRAFT編程:使用Python語言玩轉我的世界
- 微課學人工智能Python編程
- PHP與MySQL權威指南