Created
May 19, 2022 15:25
-
-
Save lazyvar/0c59567104cb9875dd7135bbb8f01ae4 to your computer and use it in GitHub Desktop.
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
// Equatable+nil.swift | |
struct Model: Equatable { } | |
let model = Model() | |
print(model == nil) // This compiles and produces a warning | |
print(model == .none) // This compiles with no warning |
Author
lazyvar
commented
May 19, 2022
I guess synthesized equatable definitions will produce something like this:
struct HandModel {
static func == (lhs: HandModel, rhs: HandModel) -> Bool {
return true
}
static func == (lhs: HandModel, rhs: HandModel?) -> Bool {
guard let rhs = rhs else { return false }
return lhs == rhs
}
}
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment