今天,我读了这样的代码,这让我感到困惑。参数“错误”之后的问号是什么意思?
if error? == nil {
self.updateDate(NSDate())
self.updateImage(originalPrice, newPrice: price!)
self.updatePrice(price!)
}
编辑:错误的定义是从这里开始
public func requestPrice(completion: PriceRequestCompletionBlock)
public typealias PriceRequestCompletionBlock = (price: NSNumber?, error: NSError?) -> ()
tracker.requestPrice { (price, error) -> () in
if error? == nil {
self.updateDate(NSDate())
self.updateImage(originalPrice, newPrice: price!)
self.updatePrice(price!)
}
}
问号用于可选项的展开。
但是在这种情况下,它什么也不做。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句