# Comparing enum cases while ignoring associated values

**URL:** <https://forums.swift.org/t/comparing-enum-cases-while-ignoring-associated-values/15922>\
**Category:** Using Swift\
**Created:** [September 6, 2018, 9:06pm UTC](https://forums.swift.org/t/comparing-enum-cases-while-ignoring-associated-values/15922 "2018-09-06T21:06:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Naxum](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/naxum/32/3174_2.png) [@Naxum](https://forums.swift.org/u/Naxum)\
**Post date:** [September 6, 2018, 10:11pm UTC](https://forums.swift.org/t/comparing-enum-cases-while-ignoring-associated-values/15922/2 "2018-09-06T22:11:13Z")

</div>

My only use of Sourcery is to auto-generate a subtype on my associated value enums so I can do simple `==` and `!=` checks for their case names. I would love to see this feature exist in Swift.

It should be easy to do things like the following without resorting to weird quirks or a bunch of extra code

```swift
enum State {
  case ready
  case loading(reasons: [String])
}

let stateA = State.ready
let stateB = State.loading(reasons: ["ReasonA", "ReasonB"])

print(stateA.case == stateB.case) //false

if stateA.case != .loading { 
  // do something
}
```

There are a bunch of hiccups when writing `if case let something = .enumCase` (including the inability to use `!=` with `case let`).  
I too would love to see it simplified!

---

_[View the full topic](https://forums.swift.org/t/comparing-enum-cases-while-ignoring-associated-values/15922)._
