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)

  • 相关阅读:
    Redis批量删除key的小技巧,你知道吗?
    Spring条件注解@Conditional
    Spring Boot 2.X 如何快速集成单元测试?
    idea git提交时候提示 --author 'java_suisui' is not 'Name ' and matches no existing author
    Spring Boot 2.X 如何添加拦截器?
    SpringMVC+Mybatis 如何配置多个数据源并切换?
    Spring Boot 2.X 如何优雅的解决跨域问题?
    基于SSL实现MySQL的加密主从复制
    mysql -- mysql基于ssl的主从复制
    MySQL DB 主从复制之SSL
  • 原文地址:https://www.cnblogs.com/dhui69/p/11158949.html
Copyright © 2011-2022 走看看