LUA upvalue使用陷阱一例

CA = {}

CA.TestCb = function(self, cb)
    if not self._cb then
        self._cb = function() cb() end
    end

    self._cb()
end

CA:TestCb(function()
    print("cb1")
end)

CA:TestCb(function()
    print("cb2")
end)

 

posted @ 2018-02-28 18:26  时空观察者9号  阅读(536)  评论(0编辑  收藏  举报