String Interpolation

Imperatorn johan_forsberg_86 at hotmail.com
Wed Oct 25 21:53:52 UTC 2023


On Wednesday, 25 October 2023 at 20:07:32 UTC, bachmeier wrote:
> On Wednesday, 25 October 2023 at 19:15:42 UTC, duckchess wrote:
>
>> ```d
>> writeln(i!"${foo++}"); // error, cant mutate foo. need to use 
>> explicit mixin(i!"${foo++}")
>> ```
>
> If someone wants to do this, they clearly don't understand the 
> purpose of string interpolation. Code like that should be 
> reserved for the C preprocessor.

However, that should work. In C# it's nothing strange with doing

string s = $"Something {++foo}" or whatever since it's just 
normal code inside the {}


More information about the Digitalmars-d mailing list