开关和选项
结果为可选的一些示例情况。
var result: AnyObject? = someMethod()
switch result {
case nil:
print("result is nothing")
case is String:
print("result is a String")
case _ as Double:
print("result is not nil, any value that is a Double")
case let myInt as Int where myInt > 0:
print("\(myInt) value is not nil but an int and greater than 0")
case let a?:
print("\(a) - value is unwrapped")
}