Strange implicit conversion integers on concatenation

uranuz neuranuz at gmail.com
Mon Nov 5 16:15:54 UTC 2018


On Monday, 5 November 2018 at 15:58:40 UTC, Adam D. Ruppe wrote:
> On Monday, 5 November 2018 at 15:36:31 UTC, uranuz wrote:
>> I believe that following code shouldn't even compile, but it 
>> does and gives non-printable symbol appended at the end of 
>> string.
>
> Me too, this is a design flaw in the language. Following C's 
> example, int and char can convert to/from each other. So string 
> ~ int will convert int to char (as in reinterpret cast) and 
> append that.
>
> It is just the way it is, alas.

Ok. It's because string is array of char. And int could be 
implicitly converted to char if it fits the range.


More information about the Digitalmars-d mailing list