Skip to content

Instantly share code, notes, and snippets.

@veritech
Last active December 8, 2016 00:23
Show Gist options
  • Save veritech/82c073e862e1885867dd316474a2847d to your computer and use it in GitHub Desktop.
Save veritech/82c073e862e1885867dd316474a2847d to your computer and use it in GitHub Desktop.
ExampleB
class Object: NSObject {
let name:String
init(name:String) {
self.name = name
}
}
func ==(lhs: Object, rhs:Object) -> Bool {
return lhs.name == rhs.name
}
func ==(lhs: Object?, rhs:Object?) -> Bool {
guard let l = lhs, let r = rhs else {
return lhs === rhs
}
return l == r
}
func doSomethingWhenTheStringMatches() {
print("Match")
}
var a:Object?
var b:Object?
if a == b {
doSomethingWhenTheStringMatches()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment