32 lines
521 B
Swift
32 lines
521 B
Swift
|
import Foundation
|
||
|
|
||
|
extension String {
|
||
|
|
||
|
var singleLined: String {
|
||
|
components(separatedBy: .newlines)
|
||
|
.joined(separator: " ")
|
||
|
}
|
||
|
|
||
|
var trimmed: String {
|
||
|
trimmingCharacters(in: .whitespacesAndNewlines)
|
||
|
}
|
||
|
|
||
|
var nonEmpty: String? {
|
||
|
self != "" ? self : nil
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension Array where Element == String {
|
||
|
|
||
|
var list: String {
|
||
|
joined(separator: ", ")
|
||
|
}
|
||
|
}
|
||
|
|
||
|
extension Sequence where Element == String {
|
||
|
|
||
|
var sortedList: String {
|
||
|
sorted().list
|
||
|
}
|
||
|
}
|