next enum in swift

enum Iter: Int{
    case s1=0, s2, s3, s4
    mutating func next(){
        if self == .s4 {
            self = .s1
            return
        }
        self = Iter.fromRaw(self.toRaw()+1)!
    }
}

var s = Iter.s1

for i in 1 .. 10 {
    println(s.toRaw())
    s.next()
}

博客园的编辑器支持好简陋

posted @ 2014-06-04 11:45  summernight  阅读(198)  评论(0编辑  收藏  举报