Right now I have an array that when printing just shows what number I sent. I would like the word to "car"be in front of each array number. For example: I enter 1 and 2 into an array. When an array is called, it will look like [car 1, car 2]not [1,2].
"car"
[car 1, car 2]
[1,2]
I added my array variable and what I call to print the array:
var arrayOfInt = [Int]() label.text = String(describing: arrayOfInt)
Try the following:
let arrayOfInt: [Int] = [1, 2] let cars = arrayOfInt.map { "car \($0)" }
as a result, the array carswill be:
cars
["car 1", "car 2"]
finally, convert to a string as before:
label.text = String(describing: cars)
Array.map , . , , .
Array.map
Source: https://habr.com/ru/post/1676574/More articles:Install the .NET Framework version for ScriptComponentProject - bimlCalling `atexit` when dynamically connecting to libc on Linux - cChanging the .NET Framework in an Integration Services Project - ssisWhy can you access meters outside the scope? - c ++In Java, is it possible to return more than one value from a catch catch block? - javaR - from long to wide and back to the same long format - rRead file in macOS command line project - xcodeUsing an audio clip causing a memory leak - iosWhy does this Spark code raise java.io.NotSerializableException - javaSKAction playSoundFileNamed Π½Π΅ ΡΠ΄Π°Π»ΠΎΡΡ Π² 500 mp3 - iosAll Articles