0

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.

sudom82
  • 135
  • 2
  • 12
  • It uses the underlying JVM implementation for `Object.hashCode`, which varies between VMs. See [this answer](http://stackoverflow.com/a/26975908/1870803) fot more details. – Yuval Itzchakov Oct 08 '16 at 18:29

1 Answers1

2

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.

Reactormonk
  • 21,472
  • 14
  • 74
  • 123