为什么这不起作用?
var lottoTaulukko = [Int]()
var finalLottoTaulukko = [[Int]]()
var laskuri1 = 0
var laskuri2 = 0
while laskuri2 < Int(riviLaskuri) {
while laskuri1 < Int(lottoMuoto) {
showRowsLabel.stringValue += "\(lottoTaulukko[laskuri1])"
finalLottoTaulukko[laskuri2][laskuri1] = lottoTaulukko[laskuri1] // ERROR IS HERE IN THIS LINE! fatal error: Index out of range
showRowsLabel.stringValue += " "
laskuri1 += 1
}
laskuri1 = 1
showRowsLabel.stringValue += "\n"
if laskuri2==10 {showRowsLabel.stringValue += "\n"}
lottoTaulukko.shuffle()
laskuri2 += 1
}
最佳答案
同样指定数组大小:
let size = ARRAY.count
并检查它是否适合您!