Post

I wish Python had enums with associated values, similar to how enums work in Swift (literally the only feature in Swift I actually like)

0 reposts0 likes

#swiftlang enums (tagged unions) are fantastic for modeling sum types in particular. But I wish Swift also had simple untagged unions: union Fruit = Apple | Orange vs enum Fruit { case .apple(Apple) case .orange(Orange) } Because tags often stand in the way of writing readable and expressive code.