About string and int spliced together.

Steven Schveighoffer schveiguy at gmail.com
Thu Jun 18 13:59:42 UTC 2020


On 6/18/20 6:19 AM, JN wrote:
> On Thursday, 18 June 2020 at 09:44:15 UTC, Kagamin wrote:
>> You can use https://dlang.org/phobos/std_conv.html#text
>> string s = text("My name is ", name, " and my age is ", age, ".");
> 
> That looks actually quite nifty, I'll have to use that someday. Still it 
> requires an import for std.conv, and when you import std.conv you might 
> as well just to!string all the way.

age.to!string will allocate a temporary string just to throw it away. 
text will not do that.

-Steve


More information about the Digitalmars-d mailing list