[Issue 11415] New: Assign range to array

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Nov 1 18:28:22 PDT 2013


http://d.puremagic.com/issues/show_bug.cgi?id=11415

           Summary: Assign range to array
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: druntime
        AssignedTo: nobody at puremagic.com
        ReportedBy: daniel350 at bigpond.com


--- Comment #0 from daniel350 at bigpond.com 2013-11-01 18:28:20 PDT ---
I would have expected the following to work:

int[] d = [1,2,3,4,5,6,7];
d[] = d.filter!(x => x > 3)[];

Where the rhs could have been assigned to the lhs.
Unfortunately this gives the following:

Error: cannot implicitly convert expression (f.opSlice()) of type
FilterResult!(__lambda2, int[]) to int[]



For now, the only idiomatic solution I could find is this roundabout way:

auto t = d.filter!(x => x > 3).copy(d);
d = d[0 .. $ - t.length];

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list