Created
December 25, 2019 13:40
-
-
Save DaisukeNagata/e89d1cd160f0298b7958e5efb761cfda to your computer and use it in GitHub Desktop.
Swift_Hashable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public struct ItemUniqueID: Hashable | |
{ | |
var sectionIDHash: Int | |
var itemIDHash: Int | |
init<SectionID: Hashable, ItemID: Hashable>(sectionID: SectionID, itemID: ItemID) | |
{ | |
sectionIDHash = sectionID.hashValue | |
itemIDHash = itemID.hashValue | |
} | |
} | |
let d = ItemUniqueID.init(sectionID: "123", itemID: "345E") | |
print(d.sectionIDHash) | |
print(d.itemIDHash) | |
var hasher = Hasher() | |
hasher.combine(d.sectionIDHash) | |
hasher.combine(d.itemIDHash) | |
let hash = hasher.finalize() | |
print(hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment