Skip to content

Instantly share code, notes, and snippets.

@drewlesueur
Created November 7, 2011 04:50
Show Gist options
  • Save drewlesueur/1344204 to your computer and use it in GitHub Desktop.
Save drewlesueur/1344204 to your computer and use it in GitHub Desktop.
My First Dart Closure
main() {
var incMaker = () {
var x = 0;
var inc = () {
x += 1;
return x;
};
return inc;
};
var inc = incMaker();
print(inc());
print(inc());
print(inc());
}
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