diesieben07
09/21/2017, 7:33 AM==
it will never call an extension function (same if you call equals
directly), since the equals
in Any
always has higher precedence.bdawg.io
09/21/2017, 7:35 AMValue.equals(Value): Boolean
is representing the method signature, not a fun Value.equals(other: Value): Boolean
extension function (granted vague since the primary difference is the absence of fun
)diesieben07
09/21/2017, 7:35 AMuli
09/21/2017, 7:35 AMdiesieben07
09/21/2017, 7:35 AMequals
you must override hashCode
. Otherwise bad things happen.uli
09/21/2017, 7:36 AMbdawg.io
09/21/2017, 7:36 AMuli
09/21/2017, 7:38 AMAny
, results of different equal
and hashCode
might get mixedjstuyts-squins
09/21/2017, 7:40 AMequals
, you should also override equals(Any?)
. The latter probably invokes the overloaded variant at some point. This way everything works, and the compiler can still pick the most suitable one, skipping useless null
and is
checksbdawg.io
09/21/2017, 7:41 AMA.plus(a: Any?)
vs B.plus(b: B)
(given B extends A)uli
09/21/2017, 7:41 AMA.plus(a: Any?)
vs B.plus(b: B)
bdawg.io
09/21/2017, 7:42 AMcompareTo
dispatches to the overloaded methods, but I think greater/less comparisons are just as important as equal value comparisonsjstuyts-squins
09/21/2017, 7:43 AMuli
09/21/2017, 7:43 AMplus
-operator it is OK, because there is no generic version (i.e. A.plus(a: Any?)
)A.plus(a: Number)
bdawg.io
09/21/2017, 7:46 AM==
convention compared to the othersoperator fun Any.plus(other: Any?): Any
as a valid extension function that would be dispatched to in any context that has it importeduli
09/21/2017, 7:47 AMbdawg.io
09/21/2017, 7:50 AM