(1)加减乘除
(2)三目运算,切记后面的空格如果不加会报错的。估计是苹果的bug。
(3)聚合运算符,省却了一个判断,很人性化
(4)区间运算符
- //加减乘除等等
- let a = 2
- let b = 3
- var c = 0
- c++
- ++c
- c+=2
- c-=2
- c*=2
- c/=2
- //三目运算符
- a==b ? "x" : "y"
- //nil聚合运算符
- var sa:String? = "a"
- var sb:String = "b"
- sa = nil
- sa ?? sb
- //区间运算符
- //闭区间
- for index in 1...10 {
- println(index)
- }
- //半闭区间
- for index in 1..<10 {
- println(index)
- }
- let arr = ["x","y","z"]
- for i in 0..<arr.count{
- println(arr[i])
- }