swift enum

前端之家收集整理的这篇文章主要介绍了swift enum前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
//: Playground - noun: a place where people can play


importCocoa


varstr ="Hello,playground"


enumDirection{

caseNorth

caseSouth

caseEast

caseWest

}


v1 =Direction.North;

varv2:Direction= .South;

switchv2{

case.North:

println("north");

case.South:

"south");

case.East:

"east");

case.West:

"west");

default:

"other");

}


enumsequence:Int{

casefirst =1,second,third

}


v3:sequence=sequencefirst;

letv4 =v3.rawValue;

println(v4);


varv5 =sequence(rawValue:3);

v5);

原文链接:https://www.f2er.com/swift/326949.html

猜你在找的Swift相关文章