Step into Swift logo

What is a Hashable?

Hashable

Hashable

  • Used internally by sets and dictionaries to make lookups consistently fast.
  • Can reduce its value to single Int.
  • Allows use of object as keys in dictionary.
  • Allows custom types to be comparable via hashable.
  • Types such as Strings, integers, floats and boolean values already conform to hashable.
  extension GridPoint: Hashable {
    ...
  }

< All Posts