I'm trying to simplify
var isReachable = {
switch status {
case .reachable: return true
default: return false
}
}()
to something like
var isReachable = (case status == .reachable)
Here is the full example:
enum NetworkReachabilityStatus {
case unknown
case notReachable
case reachable(Alamofire.NetworkReachabilityManager.ConnectionType)
}
NetworkReachabilityManager().listener = { status in
var isReachable = {
switch status {
case .reachable: return true
default: return false
}
}()
}
This is only an issue when you are dealing with enums with associated values. Any suggestions?
var isReachable: Bool = { if case .reachable = status { return true }; return false }()