Created
July 30, 2016 11:10
-
-
Save osyo-manga/0606f28608a32d479531586610a63b39 to your computer and use it in GitHub Desktop.
This file contains hidden or 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! Foo() | |
let x = 0 | |
function! Bar() closure | |
let x += 1 | |
return x | |
endfunction | |
return function('Bar') | |
endfunction | |
let Count = Foo() | |
echo Count() | |
" => 1 | |
echo Count() | |
" => 2 | |
echo Count() | |
" => 3 | |
let Count2 = Foo() | |
echo Count() | |
" => 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment