// We have this enum.
enum Formula {
case proposition(String)
indirect case negation(Formula)
indirect case operation(op: String, lhs: Formula, rhs: Formula)
var nnf: Formula { /* ... */ }
}
// And now ...
switch formula.nnf {
case .proposition(_):
return formula.nnf
case .negation(_):
return formula.nnf
case .operation(_, _, _):
return formula.nnf
}
guard let reachability = Reachability(), reachability.isReachable == true else {
// No network connection available. Do stuff.
...
}
While this works, it's not immediately readable and creates confusion. Mis-using Swift's control flow. Did not pass code review.
if let _ = detailInformation {
loadDetailInformation()
}
when optionals are killing yourself
var validAccountData = account.email != nil
validAccountData = account.firstName != nil
validAccountData = account.lastName != nil
if validAccountData {
return account
}
return nil
Proper validation