在d中加入字符串数组

qed*_*qed 3 string d

在python我可以这样做:

In [1]: x = ["a", "b", "c"]

In [2]: "--".join(x)
Out[2]: 'a--b--c'
Run Code Online (Sandbox Code Playgroud)

d中是否有相同的技巧?

Vla*_*eev 6

是的,使用std.array.join:

import std.array, std.stdio;

void main()
{
    auto x = ["a", "b", "c"];
    writeln(x.join("--"));
}
Run Code Online (Sandbox Code Playgroud)

请注意,与Python相比,D的参数顺序是相反的.

  • 在D参数顺序是自然的.在Python中,它是相反的. (5认同)