Created
May 31, 2010 04:05
-
-
Save mattn/419513 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! s:make_counter(init) | |
let ret = {"count": a:init} | |
function! ret.countup() dict | |
let self.count = self.count + 1 | |
return self.count | |
endfunction | |
return ret | |
endfunction | |
unlet! c | |
let c = s:make_counter(0) | |
echo c.countup() | |
echo c.countup() | |
echo c.countup() | |
echo c.countup() | |
echo c.countup() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment