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)

  • 相关阅读:
    mac添加环境变量
    Flex 中文字体终极解决方案
    C# Label背景透明
    C# 字节数组和十六进制字符串之间转换的另类写法
    C# params 动态参数
    HttpFlexSession注册失败的怪问题
    sun.misc.BASE64Encoder找不到jar包的解决方法
    Eclipse jee 3.7常用插件安装手记
    GitHub安装缓慢甚至下载失败的解决办法
    subclipse解决JavaHL不可用的问题
  • 原文地址:https://www.cnblogs.com/dhui69/p/11158949.html
Copyright © 2011-2022 走看看