Can I override colon operator in Lua?
Lua is using colon operator (:
) as instance开发者_运维百科 method calling. Can I override this operator for another purpose?
No, you can't. There is no such thing as colon operator- it's pure syntactic sugar.
obj:func() == obj.func(obj)
This does, however, mean that you can override the dot operator used here and the function call operator of the return value.
精彩评论