u is a dictionary and w is [u], which is an array containing that
dictionary:

julia> w = [Dict()]
1-element Array{Dict{Any,Any},1}:
 Dict{Any,Any}()

julia> u = w[1] = Dict()
Dict{Any,Any} with 0 entries

julia> u
Dict{Any,Any} with 0 entries

julia> w
1-element Array{Dict{Any,Any},1}:
 Dict{Any,Any}()

julia> u === w[1]
true

On Fri, May 6, 2016 at 1:36 AM, David Dill <[email protected]> wrote:

> I'm a novice, so forgive me if this is a silly question.  I have made a
> reasonable effort to find it in the manual and in google searches.
>
> Q: What the heck is going on here, and where are questions like this
> answered in the Julia documentation?
>
> # One copy of Dict or two?
> julia> x = y = Dict()
> Dict{Any,Any} with 0 entries
>
> # Exactly what I expect!
> julia> is(x,y)
> true
>
> # Try assigning to a vector
> julia> w = [Dict()]
> 1-element Array{Dict{Any,Any},1}:
>  Dict{Any,Any}()
>
> julia> u = w[1] = Dict()
> Dict{Any,Any} with 0 entries
>
> # WHOA!!  Two copies?
> julia> is(u, w)
> false
>
>

Reply via email to