标签:swift 笔记 fallthrough case break
1、Swift 无需写break,所以不会发生这种贯穿(fallthrough)的情况。2、//用不到变量名,可用“_”替换for _ in 1...power { answer *= base }
case 1...3: naturalCount = "a few"
let anotherPoint = (2, 0) switch anotherPoint { case (let x, 0): println("on the x-axis with an x value of \(x)") case (0, let y): println("on the y-axis with a y value of \(y)") case let (x, y): println("somewhere else at (\(x), \(y))") } // 输出 "on the x-axis with an x value of 2"
let yetAnotherPoint = (1, -1) switch yetAnotherPoint { case let (x, y)where x == y: println("(\(x), \(y)) is on the line x == y") case let (x, y) where x == -y: println("(\(x), \(y)) is on the line x == -y") case let (x, y): println("(\(x), \(y)) is just some arbitrary point") } // 输出 "(1, -1) is on the line x == -y"
2014年07月03日
标签:swift 笔记 fallthrough case break
原文地址:http://blog.csdn.net/u011439689/article/details/36867923