let point = (1,1)
switch point {
case (0,0):
print("the origin")
case (_,0):
print("on the x-axis")
case (0,_):
print("on the y-axis")
case (-2...2,-2...2):
print("inside the box")
default:
print("many")
}
用法2:
func sum(_ v1:Int,_ v2:Int) -> Int{
return v1 + v2
}
sum(10, 20)
计算属性的值是可能发生变化的(即使是只读计算属性)
有set方法的话必须有get方法,有get方法可以没有set方法
可以通过static定义类型属性,如果是类可以使用关键字class
用required修饰指定初始化器,表明其所有子类都必须实现该初始化器(通过继承或者重写实现)
如果子类重写了required初始化器,也必须加上required,不用加override
swift里的extension 相当于OC的category
匿名函数
block