initialization - How to initialize all members of an array to the same value in Swift? -


i have large array in swift. want initialize members same value (i.e. 0 or other value). best approach?

actually, it's quite simple swift. mentioned in apple's doc, can initialize array same repeated value this:

with old swift version:

var threedoubles = [double](count: 3, repeatedvalue: 0.0) 

since swift 3.0:

var threedoubles = [double](repeating: 0.0, count: 3) 

which give:

[0.0, 0.0, 0.0] 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -