split array into string in swift

To split an array into a string, you can use the joined method provided by Swift. Here's an example:

main.swift
let myArray = ["apple", "banana", "orange"]
let result = myArray.joined(separator: ", ")
print(result) // Output: apple, banana, orange
136 chars
4 lines

In the example, myArray contains three elements. Then, joined method is called on myArray to join them into a single string with a separator of ", ". Finally, the result is printed to the console.

gistlibby LogSnag