1
以下代碼給出錯誤The operator 'expr.[idx]' has been used an object of indeterminate type based on information prior to this program point. Consider adding further type constraints
。我想我已經告訴過它的類型。哪裏不對?F#2d數組索引錯誤
let board = Array2D.init 30 30 (fun x y -> 0)
let tickCell x y board : int[,] =
match board with
|board when board.[x].[y] = 0-> 1
|board when board.[x].[y] = 1-> 0
| _ -> -1
let board2 = Array2D.init 30 30 (fun x y -> tickCell x y board)
感謝細胞爲您的幫助 –
請注意,使用原始語法,您的類型註釋是針對'tickCell'函數的返回類型,而不是'board'參數的類型。 – Brian