string interpolation fun
Steven Schveighoffer
schveiguy at gmail.com
Thu Dec 13 16:01:52 UTC 2018
On 12/13/18 10:53 AM, Steven Schveighoffer wrote:
> void main()
> {
> import std.stdio;
> int x = 1;
> int y = 2;
> auto s = make!(S, i"x: $(y), y: $(x)"); // name the fields to assign
> auto s2 = make!(S, i":$(x), :$(y)"); // use symbol name as field name
> auto s3 = make!(S, i"x: $(6), y: $(7)"); // use literals to assign
> writeln(i"$(s), $(s2), $(s3)"); // runtime parameters
> }
>
>
Also, this would be a lot less noisy if we didn't need the parens after
the $, but the PR doesn't support that (yet?).
-Steve
More information about the Digitalmars-d
mailing list