Isn't there a risk of getting the same identity ha...
# webassembly
e
Isn't there a risk of getting the same identity hash code for different instances with
Random.nextInt()
? https://github.com/JetBrains/kotlin/blob/f50909d33de10ea77444d277c24fab0d8c2f10bc/libraries/stdlib/wasm/builtins/kotlin/Any.kt#L62
p
There is only equals consistency for hash code. It is normal when two different objects can have same hash code.
1
e
Yeah I guess I should reword to "Isn't there an high chance of collisions with Random?"
b
+1, there is no such a guarantee/contract like (identity)HashCode should be unique
e
Sounds reasonable! Thanks!
b
also the method you are referring is implementation detail of default Any::hashCode
✔️ 1