You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: doc/src/manual/variables-and-scoping.md
+6-6
Original file line number
Diff line number
Diff line change
@@ -90,7 +90,7 @@ julia> module B
90
90
julia> module D
91
91
b = a # errors as D's global scope is separate from A's
92
92
end;
93
-
ERROR: UndefVarError: a not defined
93
+
ERROR: UndefVarError: `a` not defined
94
94
```
95
95
96
96
If a top-level expression contains a variable declaration with keyword `local`,
@@ -187,7 +187,7 @@ julia> greet()
187
187
hello
188
188
189
189
julia> x # global
190
-
ERROR: UndefVarError: x not defined
190
+
ERROR: UndefVarError: `x` not defined
191
191
```
192
192
193
193
Inside of the `greet` function, the assignment `x = "hello"` causes `x` to be a new local variable
@@ -256,7 +256,7 @@ julia> sum_to(10)
256
256
55
257
257
258
258
julia> s # global
259
-
ERROR: UndefVarError: s not defined
259
+
ERROR: UndefVarError: `s` not defined
260
260
```
261
261
262
262
Since `s` is local to the function `sum_to`, calling the function has no effect on the global
@@ -343,7 +343,7 @@ hello
343
343
hello
344
344
345
345
julia> x
346
-
ERROR: UndefVarError: x not defined
346
+
ERROR: UndefVarError: `x` not defined
347
347
```
348
348
349
349
Since the global `x` is not defined when the `for` loop is evaluated, the first clause of the soft
@@ -408,7 +408,7 @@ julia> code = """
408
408
julia> include_string(Main, code)
409
409
┌ Warning: Assignment to `s` in soft scope is ambiguous because a global variable by the same name exists: `s` will be treated as a new local. Disambiguate by using `local s` to suppress this warning or `global s` to assign to the existing global variable.
410
410
└ @ string:4
411
-
ERROR: LoadError: UndefVarError: s not defined
411
+
ERROR: LoadError: UndefVarError: `s` not defined
412
412
```
413
413
414
414
Here we use [`include_string`](@ref), to evaluate `code` as though it were the contents of a file.
@@ -559,7 +559,7 @@ julia> let x = 1, z
559
559
println("z: $z") # errors as z has not been assigned yet but is local
560
560
end
561
561
x: 1, y: -1
562
-
ERROR: UndefVarError: z not defined
562
+
ERROR: UndefVarError: `z` not defined
563
563
```
564
564
565
565
The assignments are evaluated in order, with each right-hand side evaluated in the scope before
0 commit comments