Hi everyone,
so this is less of a question how this works, but more of why it is implemented that way (I am trying to get into the Julia way of thinking and sometimes language designs seem counter intuitive).
So I know that ==
falls back to ===
so if I don’t overload ==
for my own type only truly identical objects (in the sense of ===
) are treated as equal.
Intuitively I would expect ==
to return true
if it returns true
for each field.
So the following behaviour seems weird to me:
struct X
x
end
julia> X([1]) == X([1])
false
I personally would expect the behaviour of X
to follow the behaviour of its field, i.e.
julia> [1] == [1]
true
julia> [1] === [1]
false
So now I find myself going through my code and implementing this exact behaviour for all my types which is a bit tedious.
Why would anyone want this? Could anyone give me an example where my suggested default behaviour is not wanted?
Or I guess somewhere there might already be a discussion about this and I was just too stupid to find it. So I would also be grateful if someone could point me in the direction of the appropriate Git issue.