I'm wondering if I can somehow use an x, y pair as the key to my dictionary
let activeSquares = Dictionary <(x: Int, y: Int), SKShapeNode>()
Cannot convert the expression's type '<<error type>>' to type '$T1'
Type '(x: Int, y: Int)?' does not conform to protocol 'Hashable'
The definition for
struct Dictionary<KeyType : Hashable, ValueType> : ..., i.e. the type of the key must conform to the protocol
Hashable. But the language guide tells us that protocols can be adopted by classes, structs and enums, i.e. not by tuples. Therefore, tuples cannot be used as
A workaround would be defining a hashable struct type containing two Ints (or whatever you want to put in your tuple).