// 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.
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]] = []
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.