You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
487 B
30 lines
487 B
g = compiler.load([[
|
|
local a: integer = 1
|
|
function f()
|
|
return function()
|
|
return function()
|
|
a = a + 1
|
|
return a
|
|
end
|
|
end, a
|
|
end
|
|
]]
|
|
)
|
|
assert(g and type(g) == 'function')
|
|
g()
|
|
assert(f and type(f) == 'function')
|
|
h, b = f()
|
|
assert(h and type(h) == 'function')
|
|
assert(b == 1)
|
|
k = h()
|
|
assert(k and type(k) == 'function')
|
|
b = k()
|
|
assert(b == 2)
|
|
b = k()
|
|
assert(b == 3)
|
|
l = h()
|
|
assert(l and type(l) == 'function')
|
|
b = l()
|
|
assert(b == 4)
|
|
assert('integer' == math.type(b))
|