Reputation: 1436
I am looking for Scala's default hash function for hashing strings, however after some time searching I haven't found it. So, I would like to ask for the help of anyone who knows the source code of the language.
This is the hash function for Java: hashCode
Upvotes: 1
Views: 8581
Reputation: 5228
In standard Scala on the JVM, strings are regular Java strings. The hashing function is the same. Additional string operations are made available by an implicit conversion from String to StringOps.
In Scala JS there is a custom implementation. I suspect it has the same behavior as the JVM version. Here's the implementation.
The implementations for other Scala backends may vary (but I'm also not aware of any other actively developed backends).
Upvotes: 7