Accessing an Enumeration association value in Swift

后端 未结 7 779
情深已故
情深已故 2020-11-27 14:46

In this code I\'ve written a really useless enum that defines a possible Number with Int or Float.

I can\'t understand how can I access the value that

7条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 14:55

    If you're using guard, you can write like below:

    enum Action {
        case .moveTab(index: Int)
    }
    
    guard let case .moveTab(index) = someAction else { return }
    

提交回复
热议问题