Skip to content

Instantly share code, notes, and snippets.

@DaisukeNagata
Created December 25, 2019 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DaisukeNagata/e89d1cd160f0298b7958e5efb761cfda to your computer and use it in GitHub Desktop.
Save DaisukeNagata/e89d1cd160f0298b7958e5efb761cfda to your computer and use it in GitHub Desktop.
Swift_Hashable
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