首页 > 编程语言 > 详细

swift2.2 NO.4

时间:2016-03-04 00:33:05      阅读:273      评论:0      收藏:0      [点我收藏+]

////

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("")

}

 

swift2.2 NO.4

原文:http://www.cnblogs.com/yshgxm/p/5240544.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!