Last active
December 8, 2016 00:23
-
-
Save veritech/82c073e862e1885867dd316474a2847d to your computer and use it in GitHub Desktop.
ExampleB
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
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