Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create multidimensional array in swift? [duplicate]

I'm trying to push array type object to special index inside array in new Swift lang by Apple. It should look like this = [ [...], [...], ...], as I've read in the docs - NSMutableArray type is assigned to variable automatically if it's var, but even in playground it throws me 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'
like image 518
Kosmetika Avatar asked Jun 08 '14 12:06

Kosmetika


Video Answer


1 Answers

var array2d: [[Int]] = [[1,2,3,4],[5,6,7,8]]
like image 138
Tom van der Woerdt Avatar answered Sep 29 '22 13:09

Tom van der Woerdt