枚举的基本使用方法 Enumerations

枚举的基本使用方法 Enumerations
Enumeration
 enum SomeEnumeration{
case enumeration1
case enumeration2
case  enumeration3
...
}


import UIKit


enum GameEnding{
case Win
case Lose
case Draw
}
var yourScore:Int = 80
var enemyScore:Int = 90


var theGameEnding:GameEnding
if yourDcore>enemyScore{ theGameEnding = GameEnding.Win}
else if yourScore == enemyScore{theGameEnding = .Draw}
else { theGameEnding = .Lose}


switch theGameEnding
{
case.Win:println("You Win")
case.Lose:println("You Lose")
case.Drawn:println("It is a draw")


}


枚举的基本使用方法 Enumerations





本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/5280373.html,如需转载请自行联系原作者