Enumerations base type in Swift
Forums:
enum Season: Int8 {
case Summer, Fall, Winter, Spring
}
enum Align : Int {
case Left, Right, Center
}
enum Status: String {
case Busy, Available
}
let baseFall = Season.Fall.rawValue
//baseFall is 1, type Int8
let baseCenter = Align.Center.rawValue
//baseCenter is 2, type Int
let baseBusy = Status.Busy.rawValue
//baseBusy is "Busy", type String
- Log in to post comments