这是类方法调用的一种方式,懂面向对象编程都理解;
("hello, %s"):format("world")
OR
local str = "hello, %s"
string.format(str,"world")
https://www.lua.org/pil/16.html
http://lua-users.org/wiki/ColonForMethodCall
在 2016年4月29日星期五 UTC+8上午10:48:27,ch ren写道:
在init函数中,有如下语句:
return nil, ('"port" out of range 0~%s'):format(MAX_PORT)
我感觉作者意思应该是返回一个字符串描述错误信息,但是这个:
format是什么意思了?这个:format(MAX_PORT)应该是表示格式化前面字符串里面的%s,这种表示方法在lua官方文档里面有吗,找了很久没找到....,谁有这种表示方法的官方介绍吗?
谢谢!