According to the help, usual Dicts use the `isequal` function.  There is
also the ObjectIdDict which uses the === (I think):

julia> st1 = "asdf"
"asdf"

julia> st2 = "asdf"
"asdf"

julia> stt = st1
"asdf"

julia> st1==st2, st1===st2, isequal(st1, st2)
(true,false,true)

julia> st1==stt, st1===stt, isequal(st1, stt)
(true,true,true)

julia> od = ObjectIdDict()
ObjectIdDict()

julia> od[st1] = 1
1

julia> od[st2]
ERROR: key not found: "asdf"
 in getindex at dict.jl:138

julia> od[stt]
1

julia> di = Dict()
Dict{Any,Any}()

julia> di[st1]= 1
1

julia> di[st2]
1



On Sat, 2014-02-08 at 06:43, [email protected] wrote:
> So now I wonder, are strings treated specially here?
>
> In the last example, the string keys are using equality, to match x and y 
> to the key with value "test", whether it is an ASCIIString or UTF8String 
> doesn't matter.
>
> But for numbers the keys are looked up by identity (bits).
>
> I would have expected the string keys to be looked up by their memory 
> adresses (since there is no method "bits(String)"), as the docs suggest, 
> but it uses equality?
>
> Dict keys lookup implementation:
>
> * Strings -> equality -> lexicographical comparison
> * Numbers -> Identity -> bits level repr
> * Other mutable -> identity? -> memory adress
>
> Am I getting this right?

Reply via email to