Apple’s documentation and many articles suggest you can convert a substring (string.subsequence) to a string just by calling String(substring)
and in fact this works.
let str = "Hello world"
let hello = str.prefix(5) //create substr
//CREATE STRING FROM SUBSTRING
let hellostr = String(hello) //gives error
However when the substring is an optional as in the following,
let str = Optional("Hello world")
let hello = str?.prefix(5) //create substr
//CREATE STRING FROM OPTIONAL SUBSTRING
let hellostr = String(hello) //gives error
I am getting the error
"No exact matches in call to initializer "
What could be causing this error?
Thanks for any suggestions.