sudom82 sudom82 - 5 months ago 34
Scala Question

What is the Scala implementation of Hashcode for objects of type Any?

If two objects exist, that have no content and the same type, how exactly is the hashcode determined by default in Scala? Is it JVM specific or is there code in the scala github repo I could look at? (I could not find it there)

I did look for similar questions, but they were all java specific, not sure if the Scala team did anything different.


Object implements hashCode, so it comes from Java by default. Scala objects can override it. E.g. case classes will override it to be equivalent to the equality logic, and delegates to the member objects.