What is the standard idiom for implementing equals

2019-03-14 09:08发布

问题:

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.

回答1:

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.