title: How to check if enum does not match a pattern?
body: <p>Note that I have read this <a href="https://stackoverflow.com/questions/31773679/swift-switch-case-not">post</a> but that post uses a switch statement and it is supposed to do something (return true) when the pattern matches. I, on the other hand, don't want to do anything if the pattern matches and use an if-case statement.</p>
  
  <p>I have this enum:</p>
  
  <pre><code>enum MyEnum {
      case a
      case b(Int)
      case c
      case d
  }
  </code></pre>
  
  <p>Here's an instance of it:</p>
  
  <pre><code>let myEnum: MyEnum = .a
  </code></pre>
  
  <p>Now I want to do something if <code>myEnum</code> is not <code>.b</code>. Since <code>.b</code> has an associated value, I can't simply use an if statement check:</p>
  
  <pre><code>if myEnum != .b { // compiler error
      // do my thing here
  }
  </code></pre>
  
  <p>So I must use an if-case statement to pattern match it:</p>
  
  <pre><code>if case .b(_) = myEnum {
  
  } else {
      // do my thing here
  }
  </code></pre>
  
  <p>But I really hate the use of the empty if clause. That just looks unswifty to me. I tried to naïvely do this:</p>
  
  <pre><code>if case .b(_) != myEnum { // compiler error!
      // do my thing here
  }
  </code></pre>
  
  <p>Is there a better way to do this other than using an empty if clause?</p>
  
  <p>I still have code that should run regardless of whether the pattern matches, so a <code>guard</code> statement won't work.</p>