for i=1:5
if(i==1)
z = i
end
println("i = $i, z = $z")
end
i = 1, z = 1
ERROR: UndefVarError: z not defined
Stacktrace:
[1] top-level scope at ./REPL[6]:5 [inlined]
[2] top-level scope at ./none:0
Run Code Online (Sandbox Code Playgroud)
上面脚本的行为令我感到困惑。有人可以帮我理解为什么当i = 1时打印有效,而当i = 2时打印失败。
julia ×1