Convert Swift Collection to String

It might happen that you need to convert a swift Set,Array,Dictionary to string. It might be because you want to log or might just want plain string.

It is very easy to Convert Swift Collections to String by using description.

import UIKit
import Foundation

let a = ["a","b","c","d","e","f"]
let b = ["a":"A","b":"B","c":"C","d":"D","e":"E","f":"F"]
let c:Set = Set(["a","b","b","c","d","e","f"])
print(a.description)// ["a", "b", "c", "d", "e", "f"]
print(b.description)//["f": "F", "b": "B", "c": "C", "d": "D", "e": "E", "a": "A"]
print(c.description)//["d", "a", "b", "e", "f", "c"]

Try the above code in the playground. No mapping and string append is required.

A pat on the back !!