julia> x = int32(4)
4

julia> y = int64(4)
4

julia> x == y
true

julia> x in [y]
false

I'm not sure if this behaviour is expected. Logically,  if x==y evaluates 
to true, x in [y] should also evaluate to true.  The difference arises 
because the implementation for in uses 'isequal' function to check for 
equality instead of ==. 'isequal' is documented as follows.

*isequal(x, y)*

*True if and only if x and y have the same contents. Loosely speaking, this 
means x and y would look the same when printed. This is the default 
comparison function used by hash tables (Dict). New types with a notion of 
equality should implement this function, except for numbers, which should 
implement == instead. However, numeric types with special values might need 
to implement isequal as well. For example, floating point NaN values are 
not ==, but are all equivalent in the sense of isequal. Numbers of 
different types are considered unequal. Mutable containers should generally 
implement isequal by calling isequal recursively on all contents.*
Why is isequal more liberal than == in some cases (like floating point 
NaNs) and more strict than == is others (*Numbers of different types are 
considered unequal.*).  In the above case, I believe it should evaluate to 
True, but I assume there would be a good reason for it being the way it 
is.  Will someone please clarify why?

Reply via email to