简体   繁体   中英

How to optimize compiling of 2D Array in Swift

I am trying to create a 2D Array that contains 9 arrays of 14 zeros. Currently, I have this written as:

var sizes: [[Int]] = [[Int]](repeating:[Int](repeating:0, count:15), count:10)

However, this single line sends my compiling time through the roof. How can I help the compiler to properly infer the type of the array so that comping does not take so long?

Any help is appreciated, thanks! The image is of the expanded build log after the array is in the file.

在此处输入图片说明

您可以这样操作:

let sizes = Array(repeating: Array(repeating: 0, count: 15), count: 9)

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM