Consider the following extension:
extension Array where Element == String {
func foo(){
}
}
And consider the following string that I want to split so I can use the extension...
let string = "This|is|a|test"
let words = string.split(separator: "|")
The problem is words is a [Substring] and not [String] so I can't call foo() on it.
So in Swift 4, how do I split a string to return a [String] and not a [Substring]?
string.components(separatedBy: .whitespaces)will return an array of strings.map(String.init)string.components(separatedBy: ."|")