Let's say I have a massive String, so hashing it is fairly expensive.
When does the hashValue gets computed? Every time I access it as words.hashValue, or every time the String gets modified? If it's on access, is it cached?
Let's say I have a massive String, so hashing it is fairly expensive.
When does the hashValue gets computed? Every time I access it as words.hashValue, or every time the String gets modified? If it's on access, is it cached?
As the docs on
hashValuestate, that requirement onHashableis deprecated, you should be usinghash(into:)instead, which should only be called when you are storing theStringas aHashable, by using it as aDictionarykey or in aSet.For more info, see SE-0206 Hashable enhancements.