For loop with separator
a11e99z
black80 at bk.ru
Sat Jul 6 12:15:09 UTC 2019
On Saturday, 6 July 2019 at 11:48:42 UTC, berni wrote:
> On Thursday, 4 July 2019 at 17:00:33 UTC, Q. Schroll wrote:
>> The prime example is printing the comma when printing a list:
>> There is one between any two elements, but neither is one at
>> front or behind the last one.
>
> If it is just for printing commas in between, you can use
> range.join(", ")
>
> https://dlang.org/phobos/std_array.html#.join
.map!(e=>e.text).join( ", "); // map for non strings
or
.format!"%(%s, %)"; // for anything
More information about the Digitalmars-d-learn
mailing list