swift是一个新的支持iOS,OS X开发的面向对象语言。他是时髦的、强大的、易用的。
let people = ["Anna": 67, "Beto": 8, "Jack": 33, "Sam": 25] for (name, age) in people { println("\(name) is \(age) years old.") }
func configureLabels(labels: UILabel[]) { let labelTextColor = UIColor.greenColor() for label in labels { // label inferred to be UILabel label.textColor = labelTextColor } }
let cities = ["London", "San Francisco", "Tokyo", "Barcelona", "Sydney"] let sortedCities = sort(cities) { $0 < $1 } if let indexOfLondon = find(sortedCities, "London") { println("London is city number \(indexOfLondon + 1) in the list") }
let size = (20, 40) switch size { case let (width, height) where width == height: println("square with sides \(width)") case (1..10, 1..10): println("small rectangle") case let (width, height): println("rectangle with width \(width) and height \(height)") }

翻译自:https://developer.apple.com/library/prerelease/ios/referencelibrary/GettingStarted/LandingPage/index.html
點擊查看更多內容
為 TA 點贊
評論
評論
共同學習,寫下你的評論
評論加載中...
作者其他優質文章
正在加載中
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
