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)

  • 相关阅读:
    C++使用之常量的定义
    GDB学习之道:GDB调试精粹及使用实例
    [置顶] 如何在Windows 7 64位安装Python,并使用Matplotlib绘图
    [每日一题] 11gOCP 1z0-052 :2013-09-15 Enterprise Manager Support Workbench..................B9
    【cocos2d-x】Win7下配置Cocos2d-x开发环境
    PE框架学习之道:PE框架——发送报文流程
    System.UriHostNameType.cs
    System.UrlComponents.cs
    System.UriFormat.cs
    System.UriKind.cs
  • 原文地址:https://www.cnblogs.com/dhui69/p/11158949.html
Copyright © 2011-2022 走看看