Swift 枚举enum
enum methodType{
case get
case post
case put
case delete
}
枚举赋值
enum methodType:String{
case get="get"
case post="post"
case put="put"
case delete="delete"
}
let type:methodType = .get
let type2 = methodType.post
let type3 = methodType(rawValue: "put")// 返回一个可选类型 值/nil
let str=type3?.rawValue//打印字符串 "put"
print(type)
//省略写法
enum Direction:Int{
case east=0,west,north,south
}
print(Direction.north)