Created
June 27, 2016 05:31
-
-
Save akuraru/9c8ea7d25de1c8272a867d7c3c2e956c to your computer and use it in GitHub Desktop.
Equatable struct
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
struct MyStruct<T: Equatable>: Equatable { | |
let x: T; | |
} | |
func ==<T>(x: MyStruct<T>, y: MyStruct<T>) -> Bool { | |
return x.x == y.x | |
} | |
let s1 = MyStruct(x: 1) | |
let s2 = MyStruct(x: 2) | |
let r = s1 == s2 | |
print(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment