OK, So I'm having a string
and want to split it and return its parts in a string array.
This is my code :
// import std.algorithm;
string include = "one,two,three";
string[] paths = splitter(include,",");
This throws an error : Error: cannot cast from Result to string[]
Even if I try adding a cast(string[])
in front of the function call.
Any ideas?
splitter
returns a range which splits lazily.
To split eagerly, use split
from std.array
.
Alternatively, you can save the range to an array by using std.array.array
, like this:
string[] paths = include.splitter(",").array();