Why is the Swift type not Hashable?

Is there any good reason. The default Swift type does not conform to the Hashable protocol. I find many cases where I would like to use it as a dictionary key, and then I always need to add this seemingly silly extension:

extension Character: Hashable { var hashValue: Int { return String(self).hashValue } } 
+6
source share
1 answer

Instead of creating an extension, it may be much easier to just put your characters in strings.

0
source

Source: https://habr.com/ru/post/971608/


All Articles