Calling "get" anywhere in a function makes a global variable undefined. 
 Can anyone please help explaining the following?

1) without calling "get", the global variable is fine:

a=0
>
> Dicta = Dict{Int,Int}()
>
> function testGlobal()
>
>     println(a)
>
>     merge!(Dicta, Dict(1=>1))
>
> #     a=get(Dicta, 1, 0)
>
>     println(a)  
>
>     nothing
>
> end
>
>
> julia> testGlobal()
0
0

2) calling "get" (same code as above except uncommenting the "get" 
statement) and the global variable becomes undefined:

a=0
>
> Dicta = Dict{Int,Int}()
>
> function testGlobal()
>
>     println(a)
>
>     merge!(Dicta, Dict(1=>1))
>
>     a=get(Dicta, 1, 0)
>
>     println(a)  
>
>     nothing
>
> end
>
>
> julia> testGlobal()
ERROR: UndefVarError: a not defined
 in testGlobal() at /xxx/testType.jl:4

3) not calling the first println, the code works, but the global a is not 
set:

a=0
>
> Dicta = Dict{Int,Int}()
>
> function testGlobal()
>
> #     println(a)
>
>     merge!(Dicta, Dict(1=>1))
>
>     a=get(Dicta, 1, 0)
>
>     println(a)  
>
>     nothing
>
> end
>
>
>
julia> testGlobal()
1


Reply via email to