2015-06-20 75 views
0

是的,它是人vs編譯器時間,編譯器再次獲勝! 在FUNC getRecordNumber我返回布爾和字典Swift函數 - 不符合協議「布爾類型」

func getRecordNumber(recordNumber: Int32) -> (isGot: Bool, dictLocations: Dictionary <String, Double>) 
... 
return (isGot, dictLocations) 

我已經叫FUNC和質疑布爾但是經過isGot回到我得到錯誤信息

(isGot: Bool, dictLocations: Dictionary <String, Double>) Does not conform to protocol "Boolean Type" 

任何想法我有遺漏了?

回答

1

您不需要像這樣返回參數(isGot: Bool, dictLocations: Dictionary <String, Double>)。你只需告訴編譯器該函數將返回什麼類型。

這裏是實現正確的方法是:

func getRecordNumber(recordNumber: Int32) -> (Bool, Dictionary <String, Double>) 
{ 
    let isGot = Bool() 
    let dictLocations = [String: Double]() 

    return (isGot, dictLocations) 
} 
相關問題