Interpolated strings

Nick Sabalausky (Abscissa) via Digitalmars-d digitalmars-d at puremagic.com
Wed Apr 19 10:51:05 PDT 2017


On 04/17/2017 03:41 PM, Jonas Drewsen wrote:
> On Monday, 17 April 2017 at 19:12:37 UTC, Martin Tschierschke wrote:
>> defining a new method exho! (derived from echo + mixin...:-)
>>
>>   auto exho(string x)(){
>>      return mixin("writeln("~interp!x~")");}
>>
>> You can just write:
>>
>>    exho!"The number ${num} doubled is ${num * 2}!"
>
> It requires 'num' to be available to the exho function definition so
> will not
> work in the general case.

Also, it only works if you're just sending the string to writeln. It 
doesn't help the general case :(


More information about the Digitalmars-d mailing list