Search code examples
swiftxcode6-beta6

Swift error: Could not find an overload for '&&' that accepts the supplied arguments


I have been working on some tutorials for Swift. I came across a TicTacToe tutorial that I'm trying to code using Xcode 6 Beta 6. I'm getting the following error when I check the values in a dictionary: Could not find an overload for '&&' that accepts the supplied arguments. Here's my code.

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!"
 }

Solution

  • If you look at the full compiler output in the Report Navigator then you will see the message

    note: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions

    which tells you how to solve the problem.