/**
* Converts an array of integers into an array of strings idiomatically.
*
* - Parameter intArray: The input array of integers (`[Int]`).
* - Returns: A new array containing the string representation of each integer (`[String]`).
*/
func convertIntArrayToStringArray(_ intArray: [Int]) -> [String] {
// .map transforms each element in the collection.
// String.init (or shorthand { String($0) }) creates a String from each Int.
return intArray.map(String.init)
}
// --- Usage Example ---
let numbers: [Int] = [100, 200, 300, 400, 500]
// Call the conversion function
let strings: [String] = convertIntArrayToStringArray(numbers)
// Print each element
for str in strings {
print(str)
}
/*
run:
100
200
300
400
500
*/