How to create a multidimensional array in swift?

I am trying to push an object type array to a special index inside an array in Apple's new Swift lang. It should look like this: [ [...], [...], ...] , since I read docs - NSMutableArray in the document, it is automatically assigned to a variable if it is var , but even on the playground it causes errors:

 var arr = []; arr[0] = []; // Error: cannot assign to result of this expression arr.insert([], atIndex:0) // Error: 'NSArray' does not have member named 'insert' 
+6
source share
1 answer
 var array2d: [[Int]] = [[1,2,3,4],[5,6,7,8]] 
+9
source

Source: https://habr.com/ru/post/970530/


All Articles