标签:
////
enum Suit{
case Spades,Hearts,Diamonds,Clubs
func simpleDescription () ->String{
switch self
{
case .Spades:
return"Spades"
case .Clubs:
return "Clubs"
case .Diamonds:
return "Diamonds"
case .Hearts:
return "Hearts"
}
}
}
let hearts = Suit.Hearts
let heartsDescription = hearts.simpleDescription()
///
enum ServerResponse {
case Result(String,String)
case Failure(String)
}
let success = ServerResponse.Result("6:00 am","8:09 pm")
let failure = ServerResponse.Failure("Out of cheese.")
println("success")
switch success {
case let .Result(sunrise,sunset):
println(" ")
case let .Failure(message):
println("")
}
标签:
原文地址:http://www.cnblogs.com/yshgxm/p/5240544.html