Skip to content

Instantly share code, notes, and snippets.

@Siapran
Created June 21, 2015 15:16
Show Gist options
  • Save Siapran/e140eaec87ceaac60f96 to your computer and use it in GitHub Desktop.
Save Siapran/e140eaec87ceaac60f96 to your computer and use it in GitHub Desktop.
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