Concatenation/joining strings together in a more readable way
mipri
mipri at minimaltype.com
Mon Dec 30 09:41:55 UTC 2019
On Monday, 30 December 2019 at 06:47:37 UTC, Marcone wrote:
> Use Python format() style:
>
> import std;
> import std: Format = format;
>
> // format()
> string format(T...)(T text){
> string texto = text[0];
> foreach(count, i; text[1..$]){
> texto = texto.replaceFirst("{}", to!string(i));
> texto = texto.replace("{%s}".Format(to!string(count)),
> to!string(i));
> }
> return texto;
> }
This leaks too much.
writeln("Helo {} {}".format("xx", "name")); // Helo xx name
writeln("Helo {} {}".format("{}", "name")); // Helo name {}
More information about the Digitalmars-d-learn
mailing list