Example 1: guard and enum
enum State {
case idle
case loading
case loaded
case error
}
let a = State.idle
func test() -> State {
guard case .loading = a else {
return .error
}
return .idle
}
print(test())
Example 1: guard and enum
enum State {
case idle
case loading
case loaded
case error
}
let a = State.idle
func test() -> State {
guard case .loading = a else {
return .error
}
return .idle
}
print(test())