Type Aliases

typealias AudioSample = UInt16

Booleans

非boolean值不会被替代为bool,例如:

let i = 1
if i {
  // this example will not compile, and will report an error
}

Tuples

例如:HTTPStatus Code ("404", "Not Found")

let http404Error = (404, "Not Found")
// http404Error is of type (Int, String)

Access Tuple:

let (statusCode, statusMessage) = heep404Error
println("This status code is \(statusCode)")
// prints "The status code is 404"
println("The statuis message is \(statusMessage)")
// prints "The status message is Not Found"

简写,使用 _ 代替不需要的变量,例如:

let (justTheStatusCode, _) = http404Error
println("The status code is \(justTheStatusCode)")
// prints "The status code is 404"

另一种access tuple的方法:

println("The status code is \(http404Error.0)")
// prints "The status code is 404"
println("The status message is \(http404Error.1)")
// prints "The status message is Not Found"

Tuple的完整define

let http200Status = (statusCode: 200, description: "OK")

对应的access

println("The status code is \(http200status.statusCode)")
println("The status code message is \(http200status.description)")

最新文章

  1. 3.1 AngularJS必备知识
  2. IE滤镜及其使用技巧
  3. SplendidCRM中给来自EditView中的listbox控件设置选中值或数据源
  4. 基于jQuery的ajax对WebApi和OData的封装
  5. Django学习笔记(一)
  6. VMware v12.1.1 专业版以及永久密钥
  7. Javascript 原型编程初探
  8. Java 加密 AES 对称加密算法
  9. strstr和memcmp函数的实现
  10. Word Break II 解答
  11. Android仿微信气泡聊天界面设计
  12. ubuntu 自动获取ip的怎么设置
  13. Android 获取手机信息
  14. backend_queue.go
  15. 我的Windows装机必备软件与生产力工具
  16. BZOJ3626[LNOI2014]LCA——树链剖分+线段树
  17. django的静态文件的引入
  18. flask登录注册简单的例子
  19. 【LOJ】#2672. 「NOI2012」魔幻棋盘
  20. 关于Cocos2d-x中让主角运动的方法

热门文章

  1. Slider 滚动条 Pagination分页插件 JS Ajax 数据范围筛选 加载 翻页 笔记
  2. Sublime Text 之运行 ES6 (基于babel)
  3. 记”Uri.IsWellFormedUriString”中的BUG
  4. Zebra_Dialog 弹出层插件
  5. SpringMVC使用中遇到的问题总结
  6. DOM系列---进阶篇
  7. 实用的JS代码段(表单篇)
  8. Office2010 pro附+激活工具
  9. iOS - 视频循环播放
  10. metaspolit 基础