c++ - How to initialise a 3D array wich is of type myStruct in Swift? -


after heavy searching, found intuitive way of initialising 3d array in swift:

var firstarray = [int](count:4, repeatedvalue: 0) var secondarray = [[int]](count:4, repeatedvalue: firstarray) var thirdarray = [[[int]]](count:4, repeatedvalue: secondarray) 

it works great. can access value of thirdarray:

thirdarray[a][b][c] 

, in c++.

but if have struct like:

struct mystruct {     var color: uicolor = uicolor.redcolor()     var number: int = 0     var used: bool = true } 

how use repeatedvalue?

var firstarray = [mystruct](count:4, repeatedvalue: ???) 

simply use:

var newarray = [mystruct](count:4, repeatedvalue: mystruct()) 

the syntax creating instances of structs , classes same.


Comments

Popular posts from this blog

php - Admin SDK -- get information about the group -

dns - How To Use Custom Nameserver On Free Cloudflare? -

Python Error - TypeError: input expected at most 1 arguments, got 3 -