我在網上或在stackoverflow上找不到任何東西。 當我使用let顏色時,出現此錯誤Cannot convert value of '()' to expected argument type 'String'
。我假設我需要將()轉換爲String。無法將'()'的值轉換爲預期的參數類型'String'swift 3.0
func Change() {
print("CALL")
let colors = [
no0 = "7A9474",
no1 = "8C4482",
]
let random = Int(arc4random_uniform(UInt32(colors.count)))
let color = colors[random]
if random == current {
print("FUNNY")
Change()
}
current = random
Change2(hex: color, number: String(random)) //HERE IS THE ERROR
}
您的'let colors = [no0 = ...'代碼不是有效的Swift語法。這實際上是你的代碼? – jtbandes
我已經在發佈的代碼之外定義了變量。 –
Swift不像其他語言,其中賦值表達式'(no0 = ...)'實際上評估爲賦值。這只是一個Void表達。 – jtbandes