swift enum

版权声明:本文为博主原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/crazyeveryday/article/details/46490057
 //: Playground - noun: a place where people can play


import Cocoa


var str = "Hello, playground"


enum Direction{

    case North

    case South

    case East

    case West

}


var v1 = Direction.North;

var v2:Direction = .South;

switch v2{

case .North:

    println("north");

case .South:

    println("south");

case .East:

    println("east");

case .West:

    println("west");

default:

    println("other");

}


enum sequence:Int{

    case first = 1,second,third

}


var v3:sequence = sequence.first;

let v4 = v3.rawValue;

println(v4);


var v5 = sequence(rawValue: 3);

println(v5);


展开阅读全文

没有更多推荐了,返回首页