【发布时间】:2013-07-25 09:37:03
【问题描述】:
我正在学习 D 并尝试拆分字符串:
import std.stdio;
import std.string;
auto file = File(path, "r");
foreach (line; file.byLine) {
string[] parts = split(line);
编译失败:
Error: cannot implicitly convert expression (split(line)) of type char[][] to string[]
这行得通:
auto file = File(path, "r");
foreach (line; file.byLine) {
char[][] parts = split(line);
但为什么我必须使用char[][]?据我了解文档,它说split 返回一个string[],我更喜欢。
【问题讨论】: