Join array elements using separator

 Problem

I have an array and want to join its elements in a string, using a specific separator.



 Recipe


// Initialize the Array
var a = ["one", "two", "three"]

// Join array elements 
// using ':' as separator

var str = a.joinWithSeparator(":")
print(str)

				

Heard the news?

The Swift Cookbook for Swift 3 is at last here! For iBooks, Kindle and Paperback.
Hurry up - and Check it out! ;-)

 

 Playground