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

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
主站蜘蛛池模板: 凤冈县| 利辛县| 泰兴市| 东台市| 枣庄市| 建德市| 白山市| 罗田县| 安岳县| 青河县| 荔浦县| 孝昌县| 满城县| 阿坝县| 长阳| 修武县| 镇沅| 洪江市| 二连浩特市| 吴桥县| 富民县| 梅河口市| 南投县| 青神县| 诸暨市| 滦南县| 县级市| 定兴县| 张北县| 鲁山县| 东兴市| 台江县| 府谷县| 桑日县| 乌鲁木齐县| 辰溪县| 娄底市| 胶州市| 上饶市| 固安县| 扶沟县|