equals

Common
JVM
JS
Native
1.0
abstract fun equals(other: Any?): Boolean
(Common source) (JVM source) (JS source) (Native source)
For JVM

Returns true if this KClass instance represents the same Kotlin class as the class represented by other. On JVM this means that all of the following conditions are satisfied:

  1. other has the same (fully qualified) Kotlin class name as this instance.
  2. other's backing Class object is loaded with the same class loader as the Class object of this instance.
  3. If the classes represent Array, then Class objects of their element types are equal.

For example, on JVM, KClass instances for a primitive type (int) and the corresponding wrapper type (java.lang.Integer) are considered equal, because they have the same fully qualified name "kotlin.Int".

For JS, Native

Returns true if this KClass instance represents the same Kotlin class as the class represented by other. On JVM this means that all of the following conditions are satisfied:

  1. other has the same (fully qualified) Kotlin class name as this instance.
  2. other's backing Class object is loaded with the same class loader as the Class object of this instance.
  3. If the classes represent Array, then Class objects of their element types are equal.

For example, on JVM, KClass instances for a primitive type (int) and the corresponding wrapper type (java.lang.Integer) are considered equal, because they have the same fully qualified name "kotlin.Int".

For Common

Indicates whether some other object is "equal to" this one. Implementations must fulfil the following requirements:

  • Reflexive: for any non-null value x, x.equals(x) should return true.
  • Symmetric: for any non-null values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • Transitive: for any non-null values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • Consistent: for any non-null values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • Never equal to null: for any non-null value x, x.equals(null) should return false.

Read more about equality in Kotlin.