Привет.
Делал игру “Концентрация” по стендфордскому.
Там для структуры “Card” нужно добавить протокол hashable.
Я не понимаю, почему проект билдится и запускается без реализации в структуре hash(into:).
Никто с таким не сталкивался?
Стенфорд. Concentration
nikita.d
#1
nikita.d
#3
Да, все параметры в структуре hashable.
Т.е. required в протоколе вовсе не означает, что функцию нужно будет реализовать? Как-то это странно.
Higderin
#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 ofhash(into:)
automatically.