We have the following enum and variable
enum DisplayState{
case loading
case loaded(ViewModel)
case noResults
case error
}
var displayState:DisplayState = .loading
We want to test if we're in any state other than loaded
.
Since there is an associated value, this of course doesn't work...
if displayState != .loaded {
// Do something
}
But I'm hoping to find something else besides either of these...
switch displayState{
case .loaded: break
default: // Do something
}
or
if case .loaded = displayState {} else {
// Do something
}
So what's the simplest way to test for this case?
Try that: