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

Andrej Mitrovic andrej.mitrovich at gmail.com
Mon Nov 26 17:33:00 PST 2012


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?


More information about the Digitalmars-d-learn mailing list