-1
var tri = [[Int]]();
tri[0][0] = 321;

This code causes this error:

fatal error: Index out of range

What's wrong?

A. Bhakta
  • 33
  • 3

1 Answers1

-1

You're accessing the first element of the first subarray of the array. But your array doesn't contain any subarrays, so it crashes.

Alexander
  • 59,041
  • 12
  • 98
  • 151