split - String splitting in the D language -
i learning d , trying split strings:
import std.stdio; import std.string; auto file = file(path, "r"); foreach (line; file.byline) { string[] parts = split(line); this fails compile with:
error: cannot implicitly convert expression (split(line)) of type char[][] string[] this works:
auto file = file(path, "r"); foreach (line; file.byline) { char[][] parts = split(line); but why have use char[][]? far understand documentation, says split returns string[], prefer.
use split(line.idup);
split template function, return type depends on argument. file.byline.front returns char[] reused performance reasons. if need parts after current loop iteration have dup or idup, whatever need.
Comments
Post a Comment