On 04/30/2017 09:05 PM, bauss wrote:
On Sunday, 30 April 2017 at 16:15:41 UTC, Xinok wrote:
[...]
~ is for string concatenation, i.e.:
[...]
It's not actually a string concatenation operator, it's an array appending operator.
Appending is related but distinct. `~` does concatenation. `~=` does appending.
https://dlang.org/spec/arrays.html#array-concatenation
Strings are just an alias for immutable(char)[] and not actually a type unlike other languages like C#, Java etc. where strings are objects.
I get what you mean, but while we're splitting hairs: `string` definitely is a type. It's the same type as `immutable(char)[]`.
In fact it doesn't have any operators that doesn't work with any other type of arrays. Just like functions such as replace etc. aren't necessarily string functions, but works with any type of arrays.
Not an operator, but `foreach` has special support for transcoding between the different UTF variants.
Regarding functions, narrow strings (`string`, `wstring`) are special cased all over phobos. It's because as ranges they have dchar elements, but as arrays they have char/wchar elements. std.array.replace [1] also mentions strings in its signature because of this.
[1] https://dlang.org/phobos/std_array.html#.replace