From 68489077d099dc31e2994f4fb8c2b74a3db98f6f Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Mon, 14 Jan 2019 16:28:50 +0300 Subject: [PATCH] Update Any hashCode/equals docs --- runtime/src/main/kotlin/kotlin/Any.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/src/main/kotlin/kotlin/Any.kt b/runtime/src/main/kotlin/kotlin/Any.kt index 73b59d7310b..60c6383f373 100644 --- a/runtime/src/main/kotlin/kotlin/Any.kt +++ b/runtime/src/main/kotlin/kotlin/Any.kt @@ -16,22 +16,22 @@ public open class Any { * Indicates whether some other object is "equal to" this one. Implementations must fulfil the following * requirements: * - * * Reflexive: for any non-null reference value x, x.equals(x) should return true. - * * Symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. - * * Transitive: for any non-null reference 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 reference 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. + * * 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. * - * Note that the `==` operator in Kotlin code is translated into a call to [equals] when objects on both sides of the - * operator are not null. + * Read more about [equality](https://kotlinlang.org/docs/reference/equality.html) in Kotlin. */ @SymbolName("Kotlin_Any_equals") external public open operator fun equals(other: Any?): Boolean /** - * Returns a hash code value for the object. The general contract of hashCode is: + * Returns a hash code value for the object. The general contract of `hashCode` is: * - * * Whenever it is invoked on the same object more than once, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. - * * If two objects are equal according to the equals() method, then calling the hashCode method on each of the two objects must produce the same integer result. + * * Whenever it is invoked on the same object more than once, the `hashCode` method must consistently return the same integer, provided no information used in `equals` comparisons on the object is modified. + * * If two objects are equal according to the `equals()` method, then calling the `hashCode` method on each of the two objects must produce the same integer result. */ public open fun hashCode(): Int = this.identityHashCode()