Hash function for immutable struct containing mutable vectors

This is quite easy to check:

julia> struct A
           x::Int
           y::Vector{Int}
       end

julia> A(1, [1, 2]) == A(1, [1, 2])
false

It’s up to you whether you think this is sensible or not. People disagree.

If this is not the behaviour you want, there’s a package AutoHashEquals.jl which automates different equality and hash definitions for you

julia> using AutoHashEquals

julia> @auto_hash_equals struct A
           x::Int
           y::Vector{Int}
       end

julia> A(1, [1, 2]) == A(1, [1, 2])
true
1 Like