Except that string() also has a method for integer values. I didn’t grasp other distinctions between the two functions from the docs. But I often do clumsy things with Julia functions, (e.g. using Joins on Floating Point Values) before being corrected here. Any clarifications would be appreciated. Thanks!
I would use String() when you want to guarantee that what comes out is a standard string object.
For instance, if we were using types from InlineStrings, then we might want to eventually convert them to standard strings if we want to make containers with strings of other types. As shown below, String() will output a String while string (lowercase) will return the original type.
julia> using InlineStrings
julia> s = String7("asdf")
Thanks so much for the clarification! In general is there a place to look up such distinctions if one lacks the background to extrapolate the details from the docs? For example if I have Vector of Strings
"[\"a\", \"b\", \"c\"]"
whereas String(["a","b","c"]) without broadcasting returns a method error. But I wouldn’t have known this without the instructive Vector of Characters example provided above or just trial and error.
distinction is just that String is a type, string can be named something else like stringify or make_string_for_human_to_read.
When you call the type String, think of it as doing convert(String, x), and the mental model is if you’re representing the (logically) same data, you can do convert(), if you’re just getting the human-readable string representation of something, then you’re doing string().