Last active
February 14, 2017 14:31
-
-
Save daehn/50c83bd8832529e20c6d8523fe10ea2a to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import Foundation | |
| // Defining this breaks the behaviour of the existing '||' operator in some cases | |
| public func ||(lhs: NSPredicate, rhs: NSPredicate) -> NSPredicate { | |
| return NSCompoundPredicate(orPredicateWithSubpredicates: [lhs, rhs]) | |
| } | |
| func foo() { | |
| let cards = [String: [String]]() | |
| let startingContactIndex: UInt = 3 | |
| // This still works | |
| guard !cards.isEmpty || startingContactIndex > 0 else { | |
| return | |
| } | |
| // But when the lhs is an expression… | |
| // Binary operator '||' cannot be applied to two Bool operands | |
| guard cards.count > 0 || startingContactIndex > 0 else { | |
| return | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment