title: How to check Swift nested enums for equality of the outer enum only?
body: <p>I'm trying to use nested enums to describe my model, in a way that makes illegal states impossible and provides categorisation at the top level. Right now, my (simplified) code is:</p>
  
  <pre><code>enum SportsEvent {
  
      enum RunningEvent {
          case sprint
          case marathon
      }
  
      enum ThrowingEvent {
          case hammer
          case javelin
          case discus
      }
  
      case running(event: RunningEvent)
      case throwing(event: ThrowingEvent)
  
      func isSameCategory(as other: SportsEvent) -&gt; Bool {
  
          return false
      }
  }
  
  let sprint = SportsEvent.running(event: .sprint)
  let javelin = SportsEvent.throwing(event: .javelin)
  let hammer = SportsEvent.throwing(event: .hammer)
  
  sprint.isSameCategory(as: javelin)      // False
  hammer.isSameCategory(as: javelin)      // True
  </code></pre>
  
  <p>It feels like it should be trivial with an <code>if case ...</code> and a wildcard, but I'm not seeing how to achieve that. I'm hoping a giant switch statement isn't necessary, as my actual model is more complex.</p>