This is probably OO 101, but I'm puzzled by how references work in sets.  
Here's a minimal example.

julia> type testtype v::Bool end

julia> t1 = testtype( true )
testtype(true)

julia> t2 = testtype( false )
testtype(false)

julia> tset = Set{testtype}({t1,t2})
Set{testtype}({testtype(true),testtype(false)})

julia> t1.v = false
false

julia> tset
Set{testtype}({testtype(false),testtype(false)})

julia> t1.v = true
true

julia> tset
Set{testtype}({testtype(true),testtype(false)})


So far so good, this all makes sense to me: tset contains references to t1 
and t2, and when I make a change t1 it is reflected in tset accordingly.  
But...

julia> t1 = testtype( false )
testtype(false)

julia> tset
Set{testtype}({testtype(true),testtype(false)})



I would have thought "t1 = testtype( false )" redefined the reference, 
which would also be reflected in tset, but tset still points to the old 
value.

In that case, what is the proper way to modify a single element of tset in 
place?  With a more complicated type it may be inconvenient to modify each 
property of t1.  In particular I may have a constant value of type testtype 
that I'd like to substitute for t1.  

Reply via email to