gpt4 book ai didi

快速错误: Could not find an overload for '&&' that accepts the supplied arguments

转载 作者:行者123 更新时间:2023-11-30 10:22:03 24 4
gpt4 key购买 nike

我一直在编写一些 Swift 教程。我遇到了一个 TicTacToe 教程,我正在尝试使用 Xcode 6 Beta 6 进行编码。当我检查字典中的值时,出现以下错误:无法找到接受提供的参数的“&&”的重载。这是我的代码。

var plays = [Int:Int]()

var whoWon = ["I":0,"you":1]
for (key,value) in whoWon {
if ((plays[6] == value && plays[7] == value && plays[8] == value) ||
(plays[3] == value && plays[4] == value && plays[5] == value) ||
(plays[0] == value && plays[1] == value && plays[2] == value) ||
(plays[6] == value && plays[3] == value && plays[0] == value) ||
(plays[7] == value && plays[4] == value && plays[1] == value) ||
(plays[8] == value && plays[5] == value && plays[2] == value) ||
(plays[6] == value && plays[4] == value && plays[2] == value) || // error appears on this line
(plays[8] == value && plays[4] == value && plays[0] == value))
{
userMessage.hidden = false
userMessage.text = "Looks like \(key) won!"
}

最佳答案

我正在做同样的教程。在我看来,它必须被分解为子表达式有点奇怪,但它确实做到了,正如我在这里读到的: http://swiftlang.eu/community/34-xcode-6-beta-6-swift-can-t-handle-long-expressions/0

可能是Xcode的问题。

这是重写的函数:

func checkForWin() {
var whoWon = ["I": 0, "You": 1]
for (key, value) in whoWon {
var wonA = (plays[1] == value && plays[2] == value && plays[3] == value)
var wonB = (plays[4] == value && plays[5] == value && plays[6] == value)
var wonC = (plays[7] == value && plays[8] == value && plays[9] == value)
var wonD = (plays[1] == value && plays[4] == value && plays[7] == value)
var wonE = (plays[2] == value && plays[5] == value && plays[8] == value)
var wonF = (plays[3] == value && plays[6] == value && plays[9] == value)
var wonG = (plays[1] == value && plays[5] == value && plays[9] == value)
var wonH = (plays[3] == value && plays[5] == value && plays[7] == value)

if(wonA || wonB || wonC || wonD || wonE || wonF || wonG || wonH) {
userMessage.hidden = false
userMessage.text = "Looks like \(key) won!"
resetBtn.hidden = false
done = true
}
}
}

关于快速错误: Could not find an overload for '&&' that accepts the supplied arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25654049/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com