TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
!== operator is the referential inequality operator in Kotlin. It evaluates to true if two object references point to different memory locations (i.e., they are distinct instances), and false if they point to the exact same instance in memory. It serves as the strict negation of the referential equality operator (===).
Syntax and Translation
The operator is placed between two references:Referential vs. Structural Inequality
It is critical to distinguish!== from the structural inequality operator (!=).
!=(Structural Inequality): Evaluates whether the content or state of two objects differs. It is translated to!(a?.equals(b) ?: (b === null)).!==(Referential Inequality): Bypasses theequals()method entirely. It strictly compares the memory addresses of the references on the heap.
Behavior with Primitives and Boxing
In Kotlin 1.6 and later, using identity equality operators (=== and !==) on unboxed primitive types (such as Int, Double, Boolean) results in a strict compilation error. This is because JVM primitives are passed by value and do not possess object identity.
However, when these types are boxed (e.g., forced into an object wrapper via nullable types like Int? or generic type parameters), !== evaluates the references of the boxed objects on the heap. This behavior is subject to JVM memory optimizations, such as the Integer cache.
Restrictions with Value Classes
Applying referential equality operators (=== and !==) to value (inline) classes is strictly forbidden in Kotlin and results in a compilation error.
Because the Kotlin compiler optimizes value classes by unpredictably boxing or unboxing their underlying data at runtime, they do not possess a guaranteed, stable object identity. Consequently, evaluating memory addresses for these types is semantically invalid.
Master Kotlin with Deep Grasping Methodology!Learn More





