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 } }