swift 2
...
..<
func a(inout a) //by ref use &xx
Parameters passed to functions are constants by default, which means they can't be modified.
func incrementAndPrint(var value: Int) { //var 可修改,传值
value++
print(value)
}
Closure
var multiplyClosure: (Int, Int) -> Int
multiplyClosure = { (a: Int, b: Int) -> Int in
return a * b
}
multiplyClosure = { (a, b) in
a*b
}
multiplyClosure = {
$0 * $1 }
if you are using an optional type then you know you must handle the nil case
optional
let binding
Nil coalescing ??
计算属性可以用于类、结构体和枚举里,存储属性只能用于类和结构体
使用关键字 static 来定义值类型的类型属性,关键字 class 来为类(class)定义类型属性
@objc 可以让你的 Swift API 在 Objective-C