Created
November 7, 2011 04:50
-
-
Save drewlesueur/1344204 to your computer and use it in GitHub Desktop.
My First Dart Closure
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
main() { | |
var incMaker = () { | |
var x = 0; | |
var inc = () { | |
x += 1; | |
return x; | |
}; | |
return inc; | |
}; | |
var inc = incMaker(); | |
print(inc()); | |
print(inc()); | |
print(inc()); | |
} |
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
main() { | |
incMaker() { | |
var x = 0; | |
inc() { | |
x += 1; | |
return x; | |
} | |
return inc; | |
} | |
var inc = incMaker(); | |
print(inc()); | |
print(inc()); | |
print(inc()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment