Hi, I’ve been trying to familiarize myself with Julia lately and I finally stumbled upon a question to which I couldn’t find an answer yet, so I signed up to Discourse
First of all, thanks to everyone who contributed creating the enjoyable learning atmosphere around the Julia language!
And here goes my question:
julia> struct myInt i::Int end
julia> Base.:(==)(int::Int, my::myInt) = int == my.i
julia> m = myInt(1)
julia> 1 == m
true
julia> m == 1
false
Is there a way to mark the definition of the (==)
method as symmetric if you want to implement a symmetric operator? Then the compiler could create all permuted signatures of the method, instead of having to write them out by hand.
PS: Not using promotion mechanism on purpose here.