Created
June 21, 2015 15:16
-
-
Save Siapran/e140eaec87ceaac60f96 to your computer and use it in GitHub Desktop.
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 nouveau_compteur(increment) | |
local compte = 0 | |
return function () | |
compte = compte + increment | |
return compte | |
end | |
end | |
local incr_1 = nouveau_compteur(1) | |
local incr_2 = nouveau_compteur(2) | |
print("incr_1: " .. incr_1()) -- 1 | |
print("incr_2: " .. incr_2()) -- 2 | |
print("incr_2: " .. incr_2()) -- 4 | |
print("incr_1: " .. incr_1()) -- 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment