swift会根据我们为变量的赋值自动推导变量的类型,这个特性,在swift中叫做Type inference
var Name:Type 类型声明,type annotation
var x:Int
var s:String
Identity operator 用一性运算符
//===
//!==
三元运算符
let isSumEqualTen = isEqual ?"Yes" : "No"
cond? expr! :expr2
// opt !=nil ? opt! : b
range operator
闭区间 begin...end
[begin, end) begin ..< end
//:Half-open range operator
//begin..<{begin, end)
for index in 1..<5{
print(index)
}
逻辑运算符
- NOT ,AND ,OR .他们都返回一个Bool:
- =! 不是
- && 并且
- || 或者