lua 闭包

--匿名函数使用upvalue i保存他的计数, 闭包是一个函数加上它可以正确访问的upvalues
function newCounter()
    local i = 0
    return function()
        i = i + 1
        return i
    end
end

c1 = newCounter()
print(c1())
print(c1())