编译错误:找不到会员'下标'与&&

时间:2014-09-21 23:02:53

标签: swift xcode6 subscript

 var card:[[Int]] = bank[numberOfMarked].card;

  if ((card[0][0] == 0) && (card[1][1] == 0) && (card[2][2] == 0) && (card[3][3] == 0) && (card[4][4] == 0))
    {
     return true; 
    }

我收到错误"找不到会员'下标'并且编译器指向最后一个&&。

1 个答案:

答案 0 :(得分:0)

file a bug - 我也遇到了这个错误:note: expression was too complex to be solved in reasonable time; consider breaking up the expression into distinct sub-expressions。该表达式没有错,但是现在要在Swift中使用它,你需要将它分解为几个Bool变量:

let firstTwo = card[0][0] == 0 && card[1][1] == 0
let lastThree = card[2][2] == 0 && card[3][3] == 0 && card[4][4] == 0
if firstTwo && lastThree {
    return true
}