I’ve searched the documentation but was unable to find it. I found this answer on SO, however does any documentation exist that explains it?
type ?
followed by ==
or ===
help?> ===
search: === == !==
===(x,y) -> Bool
≡(x,y) -> Bool
Determine whether x and y are identical, in the sense that no program could distinguish them. First the
types of x and y are compared. If those are identical, mutable objects are compared by address in memory
and immutable objects (such as numbers) are compared by contents at the bit level. This function is
sometimes called "egal". It always returns a Bool value.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> a = [1, 2]; b = [1, 2];
julia> a == b
true
julia> a === b
false
julia> a === a
true
It would be good to add that answer I wrote to the manual in the appropriate place though. Would be great if someone wanted to figure out where that is an make a pull request.
Yet another issue is that searching for ==
or ===
in the docs retrieves nothing. There was a recent post somewhere where someone asked for a dictionary of the names of the operators. For example, I am not sure what I should search for if I was looking for those and the search for the symbol does not lead me the right doc page.
I guess the page is this one: Missing Values · The Julia Language
(“egal” returns nothing, but “equal to” takes us there)
I managed to find Base.:== and Core.:=== in the docs, but it wasn’t straightforward. ===
in the search bar gave no results, and ==
didn’t give a link to the docs for ==
. However, a couple of those results were Base.:!= and Base.:!==, whose docs linked to their opposites.
I had trouble finding things in the docs with the search bar before, but I didn’t expect it for the ==
and ===
operators, just seems like if the REPL’s help?>
can do it, so should the search bar.
It’s on my agenda — I think it would be best to make a section about ===
in the mathematical operations and elementary chapter since ==
and isequal
are already there and after all ===
is one of the most elementary operations, and then
- contrast
===
with==
andisequal
, - incorporate some conceptual explanation about equality from Kent Pitman’s famous post on Lisp,
- explain what’s going on with
mutable struct
andstruct
, including corner cases, - relate to hashing,
- suggest that if the user is unsatisfied with the existing comparison semantics, they should feel free to go ahead and define their own, with the tons of symbols available like
≅
.
Anything I missed, please make a suggestion.
Brilliant!
And maybe this is obvious but a link to this section should be put in the Base.:==
and Core.:===
sections in the Base docs, too, I think it’s just that important and common of a question to have.