In python I can do this:
In [1]: x = ["a", "b", "c"]
In [2]: "--".join(x)
Out[2]: 'a--b--c'
Is there an equivalent trick in d?
Yes, use std.array.join:
import std.array, std.stdio;
void main()
{
auto x = ["a", "b", "c"];
writeln(x.join("--"));
}
Note that D's argument order is reversed when compared to Python's.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With