Adding on, its also a bit much to say that Swift has a good level of sugar and reference an enum of all things. Swift's union type story is so poor that, instead of properly modeling state, people to this day still use masses of optional types in their views rather than an enum because actually using swift enums and protocols is so painful.
I don’t which Swift developers you are talking to, but let the record know I don’t and use enum quite a lot. And I don’t find it particularly painful though a bit verbose at times.
I don't think it's horrible, but I really do wish they would copy TypeScript here.
Let me do this:
const x: String | Int
Instead of enum MyEnum {
case string(String)
case int(Int)
}
There's an existing proposal for this here:https://forums.swift.org/t/re-proposal-type-only-unions/7270...
> actually using swift enums and protocols is so painful.
In what way? My understanding is they're widely used and encouraged.