I think that having three different equals operators in the language runs very much against Kotlin’s ambitions to be clear and simple.
@yole But the real problem is not having three different operators, but having three different notions of equality. And this is already the case and can’t be changed. Whenever there’s something like
>=, then a corresponding equality operator should be provided. As the consistency of
equals can’t be enforced, the induced equalities will differ.
Given three notions of equality, having three corresponding operators is the simplest solution.
@nbengtg To me, recycling
= for equality is worse than using a new third operator, assuming we can find something readable. For "not equal according to
<> is the obvious choice, with the mnemonics of "
compareTo returns something
> than zero” or simply “less or bigger”. For the opposite, I’d suggest
!<> which reads as “neither less nor bigger”. This way, all operators based on
compareTo contain some
>, which makes it pretty clear.
@Dmitry_Petrov_1 You’re surely aware that
int -> float and
long -> double are lossy and you won’t repeat the Java mistake to call them widening, will you? The only really widening conversions between integral and floating-point types in Java are
byte/short -> float and
byte/short/int -> double.