In Kotlin there are two types of equality:
Referential equality is checked by the
=== operation (and its negated counterpart
a === b evaluates to true if and only if
b point to the same object.
Structural equality is checked by the
== operation (and its negated counterpart
!=). By convention, an expression like
a == b is translated to
a?.equals(b) ?: (b === null)
a is not
null, it calls the
equals(Any?) function, otherwise (i.e.
null) it checks that
b is referentially equal to
Note that there's no point in optimizing your code when comparing to
a == null will be automatically translated to
a === null.
© 2010–2017 JetBrains s.r.o.
Licensed under the Apache License, Version 2.0.