Skip to content

Instantly share code, notes, and snippets.

@rbreve
Created April 25, 2013 04:44
Show Gist options
  • Save rbreve/5457553 to your computer and use it in GitHub Desktop.
Save rbreve/5457553 to your computer and use it in GitHub Desktop.
function newCounter ()
local i = 0
return function ()
i=i+1
return i
end
end
c1 = newCounter()
print(c1()) --> 1
print(c1()) --> 2
i=i+1
return i end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment