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

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
主站蜘蛛池模板: 逊克县| 大埔县| 松原市| 吉木乃县| 山西省| 盖州市| 鹤壁市| 山西省| 彭泽县| 永宁县| 肇源县| 来宾市| 木兰县| 潼南县| 延寿县| 浦县| 中西区| 潜江市| 怀来县| 青川县| 育儿| 三江| 电白县| 忻城县| 长海县| 鄂州市| 罗定市| 太白县| 海淀区| 永吉县| 沁源县| 仙游县| 宣威市| 加查县| 武功县| 云安县| 奉贤区| 土默特左旗| 揭东县| 苍梧县| 崇礼县|