I have a struct called Survey. It conforms to both Equatable and Hashable protocols.
import Foundation
public struct Survey {
public let id: String
public let createdAt: Date
public let updatedAt: Date
public let title: String
public let type: String
}
extension Survey: Equatable { }
public func ==(lhs: Survey, rhs: Survey) -> Bool {
return lhs.id == rhs.id && lhs.createdAt == rhs.createdAt && lhs.updatedAt == rhs.updatedAt && lhs.title == rhs.title && lhs.type == rhs.type
}
extension Survey: Hashable {
public var hashValue: Int {
return id.hashValue ^ createdAt.hashValue ^ updatedAt.hashValue ^ title.hashValue ^ type.hashValue
}
}
I can get the hash value of individual Survey objects.
But how do I get the hash value of an array containing multiple Survey objects?
public struct Survey: Hashableand get rid of everything else (except the struct variables ofcourse)get the hash value of an array containing multiple Survey objects. Include the expected code that you would like to achieve for this. Something like[survey_1, survey_N].hashValue?