枚举 Enumerations
enum SomeEnum{
case Value1
case Value2
}
// Value 无可比性
var theEnum:SomeEnum
switch theEnum{
case .value1: print("value1")
case .value2:print("value2")
}
0赞 · 0采集
beyonder1980
2015-06-09
已经知道了枚举的类型,在给出枚举值的时,可不比写出枚举类型的名,如:
switch theGameEnding
{
case .Win : do a
case .Lose: do b
}
0赞 · 0采集
beyonder1980
2015-06-09
可不设置值的数据类型
enum SomeEnumeration{
case enum1
case enum2
}
截图
0赞 · 0采集
Shuai0001
2015-05-26
枚举类型
截图
0赞 · 0采集
iThinker
2015-03-29
if theGameEnding == .Win {
println("You win!")
}
else if theGameEnding == .Lose {
println("You lose...")
}
else {
println("It's a draw.")
}
老师,是这样吗?我觉得还是switch简单啊,if的条件好麻烦啊,还是我写的麻烦了?