点号和冒号的区别:定义和调用时 ,第一个参数是否有隐藏参数self;
点号:第一个参数无隐藏参数self;
冒号:第一个参数有隐藏参数self;
eg:local test = {}
local test = {x = 1}
function test:func( arg1, arg2)
print(arg1, arg2, self)
end
function test.func1( arg1, arg2)
print(arg1, arg2, self)
end
test:func(1,2)
test.func(1,2)
test:func1(1,2)
test.func1(1,2)
结果:
1, 2, table
2, nil,1
table,1, nil
1,,2,nil