賦值
var v = 10
let l = 20
基本類型
let aInt: Int = 10
let aFloat: Float = 10.0
let aDouble: Double = 10.0
let aBool: Bool = true
let aString: String = "a"
let aWrapString:String = """
白日依山盡,
黃河入海流。
"""
let aChar: Character = "a"
let tuple = (1, "json", "success")
tuple.0
tuple.1
tuple.2
let tuple = (index: 1, type: "json", message: "success")
tuple.index
tuple.type
tuple.message
可選
let aLabel: UILabel? = UILabel()
let bLabel = aLabel!
print(type(of: bLabel))
let aLabel: UILabel? = nil
if let label = aLabel {
print(type(of: label))
} else {
}
print(aLabel?.text?.count)