function newCounter()
local i = 0
return function()
i = i + 1
return i
end
end
c1 = newCounter()
c2 = newCounter()
print(c1())
print(c1())
print(c1())
print(c1())
print(c1())
print(c1())
print("\n")
print(c2())
print(c2())
print(c2())
print(c2())
1
2
3
4
5
6
1
2
3
4
|
请发表评论