加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

枚举的基本用法 Enumerations

发布时间:2020-12-14 02:18:27 所属栏目:百科 来源:网络整理
导读:枚举的基本用法 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 theGam
枚举的基本用法 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")


}


(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读