joiner correct usage

H. S. Teoh hsteoh at quickfur.ath.cx
Wed Dec 25 10:40:18 PST 2013


On Wed, Dec 25, 2013 at 06:21:17PM +0000, Dfr wrote:
> Hello, following code:
> 
> import std.algorithm : joiner;
> string joined = joiner(["hello", "world"], " ");
> 
> Results in:
> 
> Error: cannot implicitly convert expression (joiner(...)) of type
> Result to string
> 
> Any idea how to make this work ?

joiner returns a range object, not an array. To get an array out of it,
do this:

	import std.array : array;
	import std.algorithm : joiner;
	string joined = joiner(["hello", "world"], " ").array;


T

-- 
Spaghetti code may be tangly, but lasagna code is just cheesy.


More information about the Digitalmars-d-learn mailing list