Better string mixins
Adam D. Ruppe
destructionator at gmail.com
Fri Dec 28 13:55:16 UTC 2018
On Friday, 28 December 2018 at 12:51:47 UTC, rikki cattermole
wrote:
> On 29/12/2018 1:43 AM, SashaGreat wrote:
>> mixin("x = {0}; y = {1}", x, y);
>
> mixin("x = %d; y = %d;".format(8, 4));
>
For a more direct translation, you would use positional
parameters.
mixin("x = %1$s; y = %2$s".format(x, y));
You can write your own function to pretty easily convert between
the two string formats if you want. (Or, if going that far, you
can just write your own function that avoids `format` and just
converts the args and inserts at position.)
Though these positional things are different than the
interpolation request.
More information about the Digitalmars-d
mailing list