Using Julia, I would like to reliably convert any type to type String. There seem to be two ways to do the conversion to v0.5, either a function Stringor a constructor String. The problem is that you need to choose the right option depending on the type of input.
For example, typeof(string(1))evaluated as String, but String(1)throws an error. On the other hand, typeof(string(SubString{String}("a")))evaluated as Substring{String}which is not a subtype String. Instead, we must do String(SubString{String}("a")).
So it seems like the only reliable way to convert any input xto type Stringthrough a construct:
String(string(x))
which feels a little bulky.
Am I missing something?
source
share