T[new]
Steven Schveighoffer
schveiguy at yahoo.com
Mon Aug 10 08:10:26 PDT 2009
On Mon, 10 Aug 2009 10:11:52 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> Walter Bright wrote:
>> Kagamin wrote:
>>> Of what type will strings be?
>> immutable(char)[]
>>
>>> Of what type will be the result of concatenation?
>> T[new]
>
> Hmmm, I see a problem.
>
> auto s1 = "Hello";
> auto s2 = " world";
> auto s = s1 ~ s2;
>
> Some might be surprised that the type of s is not the same as that of s1
> and s2.
auto c1 = 'a';
auto c2 = 'b';
auto c = c1 + c2;
But s is better, because it implicitly casts back to typeof(s1). I think
it's the absolutely best behavior.
-Steve
More information about the Digitalmars-d
mailing list