zoukankan      html  css  js  c++  java
  • 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)

  • 相关阅读:
    RCP中如何使用代码安装、运行plugins
    家传卤水秘方备了个份
    解决Activator X for bundle Y is invalid 以及 Activator not found
    【三分法】hdu2438 Turn the corner
    【01背包】洛谷P1282多米诺骨牌
    【动态规划】洛谷P1004方格取数
    【单调栈】最长不上升子序列变式,洛谷 P2757 导弹的召唤
    【埃氏筛】洛谷P3383埃氏筛模板
    【状压DP】poj3254 Corn Fields
    【动态规划】洛谷P1006传纸条
  • 原文地址:https://www.cnblogs.com/dhui69/p/11158949.html
Copyright © 2011-2022 走看看