DIP 1027---String Interpolation---Format Assessment

Walter Bright newshound2 at digitalmars.com
Wed Feb 26 10:25:19 UTC 2020


On 2/26/2020 2:02 AM, Juraj Mojzis wrote:
> void print_many(string msg, int cnt = 1) {
>      foreach(i; 0 .. cnt) writeln(msg);
> }
> 
> int apple_cnt = 4;
> print_many(i"I have $apple_cnt apples.");
> 
> expected: I have 4 apples.

Doing what you want would require a runtime GC allocated string.


More information about the Digitalmars-d-announce mailing list