// 原始型是整型
enum Method:Int {
case Add
case Sub
case Mul
case Div
}
print("--------------->")
// 这个还是枚举值
print(Method.Mul)
print("--------------->")
/**
把枚举转换为 Int类型 toRaw()不能用了
print(Method.Add.toRaw())
用 Method.Mul.rawValue
*/
let m =Method.Mul.rawValue
print("m===\(m)")
/**
把 Int转换为枚举
Method.fromRaw(3) 不用了
用这个 Method.init(rawValue: 3)
*/
let m1 =Method.init(rawValue:3)
print("m1==\(m1)")
let m2 = Method.RawValue(2)
print("m2==\(m2)")
print("--------------->")
print(Method.Mul.hashValue)
enum Method2:String {
case Add ="addStr"
case Sub ="subStr"
case Mul ="mulStr"
case Div ="divStr"
}
print("--------------->")
print(Method2.Div.rawValue)