Reputation: 1198
// Works!
var foo = [[Int]]()
// Neither work. Halp!
var foo = [String][Int]()
var foo = [String[Int]]()
I found this question, which leads me to believe that this can be done but is not advised.
Upvotes: 0
Views: 3776
Reputation: 648
The best practice here would be to use a tuple of two values of different types
var foo:[(String, Int)] = []
Or if you want to use values of different types
var foo:[(AnyObject, AnyObject)] = []
But if you want it to be a multidimensional array anyway, then just make it not type-specific:
var foo:[[AnyObject]] = []
Upvotes: 7