Стенфорд. Concentration


#1

Привет.
Делал игру “Концентрация” по стендфордскому.
Там для структуры “Card” нужно добавить протокол hashable.
Я не понимаю, почему проект билдится и запускается без реализации в структуре hash(into:).
Никто с таким не сталкивался?


#2

Возможно все типы в Сard определяют hashable


#3

Да, все параметры в структуре hashable.
Т.е. required в протоколе вовсе не означает, что функцию нужно будет реализовать? Как-то это странно.


#4

Всё же в документации сказано:

func hash(into: inout Hasher)`
Hashes the essential components of this value by feeding them into the given hasher.
Required. Default implementations provided.

И чуть выше:

For structs whose stored properties are all Hashable , and for enum types that have all- Hashable associated values, the compiler is able to provide an implementation of hash(into:) automatically.