We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 45d70fe commit 8047a9bCopy full SHA for 8047a9b
doc/src/manual/variables-and-scoping.md
@@ -99,6 +99,22 @@ julia> module E
99
ERROR: cannot assign variables in other modules
100
```
101
102
+If a top-level expression contains a variable declaration with keyword `local`,
103
+then that variable is not accessible outside that expression.
104
+The variable inside the expression does not affect global variables of the same name.
105
+An example is to declare `local x` in a `begin` or `if` block at the top-level:
106
+
107
+```jldoctest
108
+julia> x = 1
109
+ begin
110
+ local x = 0
111
+ @show x
112
+ end
113
+ @show x;
114
+x = 0
115
+x = 1
116
+```
117
118
Note that the interactive prompt (aka REPL) is in the global scope of the module `Main`.
119
120
## Local Scope
0 commit comments