У меня есть struct
, студент, который соответствует протоколу Hashable
, но я получаю сообщение об ошибке для метода hash(into:)
.
struct Student: Hashable{
let studentID: Int
let name: String
init(studentID id:Int, andName name: String){
studentID = id
self.name = name
}
func hash(into hasher: inout Hasher){
hasher.combine(bytes: ObjectIdentifier(self.Type)) //giving compile-time error
}
static func == (lhs: Self, rhs: Self) -> Bool{
return (lhs == rhs)
}
}
Я получаю сообщение об ошибке для функции hash(into:)
. Поскольку Student - это структура, а не класс, я не понимаю, как реализовать требуемую функцию hash(into:)
. Кто-нибудь может мне помочь, пожалуйста.