0

I'm trying to compare inequality for a single case of my associated enum.

enum ResponseEnum {
 case loading
 case success(responseArray)
 case failure(Error)
}

I can check if it is loading in a single line by writing:

if case .loading = myEnumVariable

However, I can't check for inequality in this way, I get this error: Variable binding in a condition requires an initializer.

What does this error mean?

Is there a way to check for this inequality with a single line?

teradyl
  • 2,584
  • 1
  • 25
  • 34
  • The `=` in `if case .loading = myEnumVariable` is *assignment* not an *equality* test. It doesn't make sense to replace it with `!=`. – vacawama May 07 '19 at 01:17
  • I understand that it should be assignment, but you can use it as an equality test in this weird way for enums. See the question that this was marked duplicate of, it has another example. It seems there isn't a satisfactory solution for this problem right now. – teradyl May 07 '19 at 18:00

0 Answers0