Last active
May 31, 2020 08:02
-
-
Save Zeta611/d5ffaf9e406027f0d5a506d790b06ce3 to your computer and use it in GitHub Desktop.
[Lua capture] Shows a full lexical scoping of Lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function enable_counting() | |
local count = 0 | |
local old_print = print | |
print = function(...) | |
count = count + 1 | |
old_print(...) | |
end | |
return function() return count end | |
end | |
print("Hello, Lua!") | |
counter = enable_counting() | |
print("print called "..counter().." times") | |
print("print called "..counter().." times") | |
print("print called "..counter().." times") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment