0

Is there a way to make these loops in one line of code or shorter form?

var matrix : [[Int]] = [
  [0,1,2,9],
  [3,4,5,2],
  [1,3,1,5]
]

for i in rowIndexes
{ 
  for c in 0..<nCol
  {
      matrix[i][c] = 0
  }
}

output : [[Int]] = [
  [0,0,0,0],
  [3,4,5,2],
  [1,3,1,5]
 ]
casillas
  • 16,351
  • 19
  • 115
  • 215

0 Answers0