Want to try out string interpolation in D?

matheus matheus at gmail.com
Mon Oct 23 11:12:20 UTC 2023


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.


More information about the Digitalmars-d-learn mailing list