What to use instead of array.join if RHS is not a range?

H. S. Teoh hsteoh at quickfur.ath.cx
Mon Nov 26 18:10:31 PST 2012


On Tue, Nov 27, 2012 at 02:33:00AM +0100, Andrej Mitrovic wrote:
> This is what I want:
> 
> struct S { int x; }
> 
> void main()
> {
>     S[] arr = [S(2), S(4), S(6)];
>     S s = S(0);
>     arr.join(s);  // fails here
>     assert(arr == [S(2), S(0), S(4), S(0), S(6)]);
> }
> 
> Calling join like that fails, specifically it fails because "s" is not
> a forward range (I don't know why it's implemented like that..). Is
> there some other function which can join with an element as a
> separator?

What about std.algorithm.joiner?


T

-- 
All problems are easy in retrospect.


More information about the Digitalmars-d-learn mailing list