微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

枚举的基本用法 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")


}


版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐