Accessing an Enumeration association value in Swift

后端 未结 7 777
情深已故
情深已故 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 15:06

    I have used something like this:

    switch number {
    case .int(let n):
        println("integer is \(n)")
    case .float(let n):
        println("float is \(n)")
    }
    

提交回复
热议问题