Skip to content

Instantly share code, notes, and snippets.

@AlexVegner
Created January 24, 2020 08:37
Show Gist options
  • Save AlexVegner/cf2b380fb204c6a5bf0f6875278f510a to your computer and use it in GitHub Desktop.
Save AlexVegner/cf2b380fb204c6a5bf0f6875278f510a to your computer and use it in GitHub Desktop.
dart_lexical_scope​.dart
/// Dart is a lexically scoped language, which means that the scope of variables is determined statically, simply by the layout of the code. You can “follow the curly braces outwards” to see if a variable is in scope.
// example
bool topLevel = true;
void main() { //
var insideMain = true;
void myFunction() {
var insideFunction = true;
void nestedFunction() {
var insideNestedFunction = true;
assert(topLevel);
assert(insideMain);
assert(insideFunction);
assert(insideNestedFunction);
}
nestedFunction();
}
myFunction();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment