枚举的基本用法 Enumerations

枚举的基本用法 Enumerations,第1张

概述枚举的基本用法 Enumerations Enumeration  enum SomeEnumeration{ case enumeration1 case enumeration2 case  enumeration3 ... } import UIKit enum GameEnding{ case Win case Lose case Draw } var yourScore:Int = 80 枚举的基本用法 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全部内容,希望文章能够帮你解决枚举的基本用法 Enumerations所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://www.outofmemory.cn/web/1088588.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存