Search code examples
scalaequalshashcode

What is the standard idiom for implementing equals and hashCode in Scala?


What is the standard idiom for implementing the equals and hashCode methods in Scala?

I know the preferred approach is discussed in Programming in Scala, but I don't currently have access to the book.


Solution

  • There's a free 1st edition of PinS that discuss this subject just as well. However, I think the best source is this article by Odersky discussing equality in Java. The discussion in PinS is, iirc, an abbreviated version of this article.