Want to try out string interpolation in D?

Imperatorn johan_forsberg_86 at hotmail.com
Mon Oct 23 11:43:33 UTC 2023


On Monday, 23 October 2023 at 11:12:20 UTC, matheus wrote:
> On Friday, 20 October 2023 at 16:41:40 UTC, Imperatorn wrote:
>> Here's a script to get you started
>>...
>> Now try string interpolation:
>>
>> ```d
>> import std.stdio;
>>
>> void main()
>> {
>> 	string name = "Johan";
>> 	int age = 37;
>> 	int iq = 8001;
>> 	int coffees = 1000;
>>
>> 	writeln(i"Your name is $name and you're $age years old");
>> 	writeln(i"You drink $coffees cups a day and it gives you 
>> $(coffees + iq) IQ");
>> }
>> ```
>>
>> Output:
>> ```
>> Your name is Johan and you're 37 years old
>> You drink 1000 cups a day and it gives you 9001 IQ
>> ```
>
> First of all thanks for writing this.
>
> Well this seems pretty nice... What DIP number is this? - I'd 
> like to read why it was rejected.
>
> Matheus.

Which one did you try?

The first one is YAIDIP:
https://github.com/John-Colvin/YAIDIP

and the second one is DIP1027:
https://github.com/dlang/DIPs/blob/master/DIPs/rejected/DIP1027.md

Make sure you try them both



More information about the Digitalmars-d-learn mailing list