佚名通过本文主要向大家介绍了lua 字符串操作,lua 字符串,lua字符串分割,lua 字符串截取,lua 字符串转换数字等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题:lua.dll lua的字符串操作的问题
描述:
解决方案1:
描述:
1.平时都是用string库,今天见识了下面这样用法:
local str = "hello world"
print(str:sub(1))
------
结果为:hello world
平时的用法:
local str = "hello world"
print(string.sub(str,1))
------
结果为:hello world
请问 “字符串:sub()”这种用法的出处或资料有人知道吗?
解决方案1:
这是因为lua的”语法糖的原因“
解决方案2:可以看下完整的lua程序设计2,我目前也正在学习,里面有详细的介绍
解决方案3:使用冒号将默认接收一个self参数,而使用点号则需要显式传入self参数
https://moonbingbing.gitbooks.io/openresty-best-practices/content/lua/dot_diff.html