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

String coercion

String coercion is a fancy way of asking Lua to automatically convert data types to string representations of the data. For example, a string and an integer can be combined to form a new string like the following:

pi = 3.14
message = "The rounded value of pi is: " .. pi
print(message)
print("Nine: " .. 9)

String coercion also works the other way around! Adding a string that contains only numbers to a number is valid addition:

eleven = "10" + 1
print (eleven)
print (7 + "01") -- 8
主站蜘蛛池模板: 上思县| 改则县| 湖南省| 高州市| 三江| 武川县| 万全县| 庆安县| 温宿县| 城市| 麻江县| 丽水市| 唐海县| 叙永县| 乌兰察布市| 林州市| 手游| 固始县| 浑源县| 灌阳县| 斗六市| 长春市| 灵川县| 榕江县| 中宁县| 安溪县| 二连浩特市| 衡东县| 榆林市| 右玉县| 盘锦市| 青岛市| 南宁市| 土默特左旗| 周宁县| 太仆寺旗| 东丰县| 阳原县| 佛教| 垣曲县| 马关县|