String Interpolation

IGotD- nise at nise.com
Fri Oct 27 11:53:24 UTC 2023


On Friday, 27 October 2023 at 09:47:15 UTC, Arafel wrote:
>
> Yes, these are the current proposals.
>
> Or at least not directly. You'll need to call a function for 
> that.
>
> So this will work:
>
> ```d
> writeln(i"Hello, ${name}");
> ```
>
> But this won't:
>
> ```d
> string greeting = i"Hello, ${name}";
> ```
>
> and you will need to do:
>
> ```d
> string greeting = i"Hello, ${name}".text;
> ```
>
> Walter's proposal is essentially the same in that regard, only 
> using `writefln` and `format` instead of `write` and `text`.
>
> Good luck explaining these subtleties to new / casual users.

Can't this be solved by adding a constructor in the string class 
that accepts whatever type the interpolated string is?



More information about the Digitalmars-d mailing list