Access enum associated value as optional

前端 未结 3 881
死守一世寂寞
死守一世寂寞 2021-01-26 03:01

How can I access an enum value for a specific case without having to implement an enum function for each case?

I\'m thinking something like this:

enum Re         


        
3条回答
  •  无人共我
    2021-01-26 03:43

    I'm afraid this is the most you can get:

        let error: String?
        if case .failure(let e) = resultFailure {error = e}
    

提交回复
热议问题