How should I implement Default Associated Values with Swift Enums? -
swift question there way of having enum type 1 case can have associated value. i have api gives me available filters, it's unlikely possible api add additional filter types. if api sends unknown filter type want keep information associated enum. below different ideas had doing this. my first 2 tries didn't compile. third try feels bit clunky. does have better way of doing this? think shouldn't use enum problem? typealias apifilteridentifier = string /* not compile */ enum enumtestassociatedvaleu: apifilteridentifier { case unknown(apifilteridentifier) case = "everyone" case team = "myteam" } /* not compile */ enum enumtestdefaultassociatedvalues: apifilteridentifier { case unknown(apifilteridentifier) case everyone(apifilteridentifier = "everyone") case team(apifilteridentifier = "myteam") } /* compiles there better way? */ enum enumtestwithcustominit { case unknown(apifilteridentifier) ...