Skip to content

Instantly share code, notes, and snippets.

@7foots
Last active April 28, 2020 14:06
Show Gist options
  • Save 7foots/3b4ca9efb46d989acbb84f953b8cc206 to your computer and use it in GitHub Desktop.
Save 7foots/3b4ca9efb46d989acbb84f953b8cc206 to your computer and use it in GitHub Desktop.
extension Dictionary where Key == Int64, Value == SKNode {
func int64key(_ key: (Int32, Int32)) -> Int64 {
return (Int64(key.0) << 32) | Int64(key.1)
}
subscript(_ key: (Int32, Int32)) -> SKNode? {
get {
return self[int64key(key)]
}
set(newValue) {
self[int64key(key)] = newValue
}
}
}
// Usage example
var dictionary: [Int64 : SKNode] = [:]
dictionary[(0,1)] = SKNode()
dictionary[(1,0)] = SKNode()
print(dictionary)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment