I need to read some Scala code (starting from a few hours ago), I also need to make sure how hash maps in Scala compares keys. After reading some posts, I know that the == is for value comparison, but it is not clear that hash maps (e.g. scala.collection.immutable.Map) keys are compared using value comparison (==) or reference comparison?
I need to read some Scala code (starting from a few hours ago), I
Share
The
HashMapuses==and the hashing method##to compare keys. It couldn’t use the reference because then something likeMap(List(1) -> 'a, List(1) -> 'b)would contain two entries, which would be wrong.