Created
April 27, 2020 00:19
-
-
Save ChrisMarshallNY/351a206b71c894e108f8c00393702d56 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
struct A<T: Hashable>: Hashable { | |
static func == (lhs: A<T>, rhs: A<T>) -> Bool { lhs.tVar == rhs.tVar } | |
let tVar: T | |
init(_ inVat: T) { | |
tVar = inVat | |
} | |
} | |
let arVal = [A<Int>](arrayLiteral: A(0), A(1), A(2)) | |
arVal.forEach { print($0.tVar) } | |
let arDict: [A<Int>: Int] = [ | |
arVal[0]: arVal[0].tVar, | |
arVal[1]: arVal[1].tVar, | |
arVal[2]: arVal[2].tVar | |
] | |
arDict.forEach { print("\($0.key): \($0.value)") } | |
// Prints: | |
// 0 | |
// 1 | |
// 2 | |
// A<Int>(tVar: 2): 2 | |
// A<Int>(tVar: 0): 0 | |
// A<Int>(tVar: 1): 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment