【发布时间】:2012-09-05 19:31:02
【问题描述】:
我尝试编译以下代码:
import std.algorithm;
void main()
{
string[] x = ["ab", "cd", "ef"]; // 'string' is same as 'immutable(char)[]'
string space = " ";
char z = joiner( x, space ).front(); // error
}
使用dmd 编译以错误结束:
test.d(8): Error: cannot implicitly convert expression (joiner(x,space).front()) of type dchar to char
将 char z 更改为 dchar z 确实修复了错误消息,但我很感兴趣它为什么会首先出现。
为什么joiner(string[],string).front() 的结果是 dchar 而不是 char?
(文档 http://dlang.org/phobos/std_algorithm.html#joiner 中没有任何内容)
【问题讨论】: