Type of string literal concatenated with non-immutable char array

Steven Schveighoffer schveiguy at gmail.com
Mon Feb 1 15:47:33 UTC 2021


On 2/1/21 7:17 AM, ag0aep6g wrote:
> On 31.01.21 22:48, Per Nordlöw wrote:
>> Why isn't
>>
>>      "Name " ~ name ~ " could not be found"
>>
>> implicitly convertible to `string`?
> 
> If concatenation is guaranteed to allocate a new array, then it should 
> be "strongly pure", and the conversion should work. I'm not sure if it 
> is guaranteed to allocate a new array.

It is. https://dlang.org/spec/arrays.html#array-concatenation

"Concatenation always creates a copy of its operands, even if one of the 
operands is a 0 length array"

-Steve


More information about the Digitalmars-d-learn mailing list