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 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
