swift會根據(jù)我們?yōu)樽兞康馁x值自動推導(dǎo)變量的類型,這個特性,在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
閉區(qū)間 begin...end
[begin, end) begin ..< end
//:Half-open range operator
//begin..<{begin, end)
for index in 1..<5{
print(index)
}
邏輯運算符
- NOT ,AND ,OR .他們都返回一個Bool:
- =! 不是
- && 并且
- || 或者