for loop variable name use swift -


i have static variable name want create use loop :

var imageke1 = "" var imageke2 = "" var imageke3 = "" var imageke4 = "" var imageke5 = "" var imageke6 = "" var imageke7 = "" 

i try create error expected pattern:

for var = 1; < 8; i++     {         var "imageke\(i)" = ""     } 

i try conflict same variable name (kucing) :

for var = 1; < 8; i++     {         var kucing = "imageke\(i)"         var kucing = ""     } 

at end create list of string result, , want change loop:

var names: [string] = ["\(imageke1)", "\(imageke2)", "\(imageke3)", "\(imageke4)", "\(imageke5)", "\(imageke6)", "\(imageke7)"] 

how loop variable name (imageke) , var names?

var names: [string] = []  index in 1...8 {     names.append("imageke\(index)") }  println(names)  // "[imageke1, imageke2, imageke3, imageke4, imageke5, imageke6, imageke7, imageke8]" 

Comments

Popular posts from this blog

OpenCV OpenCL: Convert Mat to Bitmap in JNI Layer for Android -

android - org.xmlpull.v1.XmlPullParserException: expected: START_TAG {http://schemas.xmlsoap.org/soap/envelope/}Envelope -

python - How to remove the Xframe Options header in django? -