Skip to content

Instantly share code, notes, and snippets.

@akuraru
Created June 27, 2016 05:31
Show Gist options
  • Save akuraru/9c8ea7d25de1c8272a867d7c3c2e956c to your computer and use it in GitHub Desktop.
Save akuraru/9c8ea7d25de1c8272a867d7c3c2e956c to your computer and use it in GitHub Desktop.
Equatable struct
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