aboutsummaryrefslogtreecommitdiffstats
path: root/WireGuard/Extensions/String+Arrays.swift
blob: b142202d3344f573fb34c89a89f7e86cb04682e1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
//  Copyright © 2018 WireGuard LLC. All rights reserved.
//

import Foundation

extension String {

    static func commaSeparatedStringFrom(elements: [String]) -> String {
        return elements.joined(separator: ",")
    }

    func commaSeparatedToArray() -> [String] {
        return components(separatedBy: .whitespaces)
            .joined()
            .split(separator: ",")
            .map(String.init)
    }

}