Skip to content

Instantly share code, notes, and snippets.

@mattn
Created May 31, 2010 04:05
Show Gist options
  • Save mattn/419513 to your computer and use it in GitHub Desktop.
Save mattn/419513 to your computer and use it in GitHub Desktop.
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