/* == ===运算符 */
var a: NSString = "abc",b = a,c: NSString = "abc"
println(a == b) //true
println(a == c) //true
println(a === b) //true
println(a === c) //false === 运算符可以判断是否对同一对象的引用
/* 三元运算符 */
var result: Bool = false
let f = result ? 0: "100" //三元运算符来赋值的时候 可以赋予不同类型数据
println(f)
/* is 对类型的判断 */
var str: NSString = "a"
println((str is NSMutableString))
/* [Any] [AnyObject] */
class people {
init() {
}
init(width: Int,height: Int) {
}
var age = 10
}
//[Any] 任何类型的数组(包括标准类型,构造体)
var ca: [Any] = ["a","a",CGSize(width: 100,height: 100),people()]
//[AnyObject] 任何非标准类型的数组(不包括包括标准类型,构造体)
var obj: [AnyObject] = [people(width: 100,people()]
原文链接:https://www.f2er.com/swift/327419.html