Passing method arguments: Tuple vs Dict

By default, two structs are considered equal if they are bitwise the same. In your example, this is not the case because the two Vectors are different vectors (even though they have the same entries). The following example should make this clear:

julia> struct Foo
           a::Vector{Int}
       end

julia> Foo([1,2]) == Foo([1,2]) # Different vectors with same entries
false

julia> a = [1,2]; Foo(a) == Foo(a)  # Same vector
true

If this is not the behaviour that you want, then you must define your own equality comparison:

julia> Base.:(==)(a::Foo,b::Foo) = a.a == b.a

julia> Foo([1,2]) == Foo([1,2]) 
true  # <- I guess this is what you wanted?
9 Likes