

The beauty of IUO is that you can ignore the nullability and you have the same amount of safety you have today: if you touch a null value you get an exception (or abort in Swift's case). There is no requirement to choose just one. It could even support all of the popular nullability annotations. The Kotlin compiler could treat every parameter and return value that doesn't have a nullability annotation as an implicitly unwrapped optional (Type!). I presume it would be pretty challenging to provide a proper compatibility with Java, transforming all nullable Kotlin values to Optional and vice-versa, especially in such tight areas like Java reflection. To make a simpler mental picture, imagine Objective-C and Swift being connected side-by-side and Kotlin and Java as a stack, where Kotlin is on top. Apple uses a bridging mechanism to connect Objective-C and Swift binaries, when Kotlin uses the same bytecode as Java. Otherwise, structural equality is used, which disagrees with the standard so that NaN is equal to itself, NaN is considered greater than any other element, including POSITIVE_INFINITY, and -0.0 is not equal to 0.0.>Unfortunately, it is not really possible to change Kotlin behave the same way. When an equality check operands are statically known to be Float or Double (nullable or not), the check follows the IEEE 754 Standard for Floating-Point Arithmetic. For values represented by primitive types at runtime (for example, Int), the = equality check is equivalent to the = check. a = b evaluates to true if and only if a and b point to the same object. Referential equality is checked by the = operation and its negated counterpart !=.

Structural equality has nothing to do with comparison defined by the Comparable interface, so only a custom equals(Any?) implementation may affect the behavior of the operator. Functions with the same name and other signatures, like equals(other: Foo), don't affect equality checks with the operators = and !=. To provide a custom equals check implementation, override the equals(other: Any?): Boolean function. Note that there's no point in optimizing your code when comparing to null explicitly: a = null will be automatically translated to a = null. If a is not null, it calls the equals(Any?) function, otherwise ( a is null) it checks that b is referentially equal to null.
