25 lines
528 B
Swift
25 lines
528 B
Swift
|
//
|
||
|
// String+Arrays.swift
|
||
|
// WireGuard
|
||
|
//
|
||
|
// Created by Eric Kuck on 8/15/18.
|
||
|
// Copyright © 2018 Jason A. Donenfeld <Jason@zx2c4.com>. 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)
|
||
|
}
|
||
|
|
||
|
}
|