0
我試圖實現返回一般枚舉值,並確定它的參數之一的通用枚舉值。返回與特定相關的數據
像這樣的事情,因爲這個枚舉:
enum {
state1(apple: Apple, color: Color)
state2(pear: Pear, color: Color)
...
}
我希望能夠返回的狀態,並確定它的價值觀之一。
...
switch state {
case .state1(_, _), .state2(_, _):
return state(...blue color...)
}
那是可能的嗎?
謝謝!
權。試圖避免重複代碼..也許一些與模板可以幫助。 – gerbil