Array start index

Bastiaan Veelo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Feb 6 08:52:36 PST 2017


On Monday, 6 February 2017 at 14:26:35 UTC, Bastiaan Veelo wrote:
> The unit test didn't detect this because it was ambiguous.

Sorry for that misinformation. I should have said that 
opIndexAssign wasn't tested. Here is a better test.

     unittest {
         OneBasedArray!int arr;
         arr = [1,2,3];
         arr ~= 4;
         arr[4] = 14;
         assert(arr.length == 4);
         assert(arr[1] == 1);
         assert(arr[2] == 2);
         assert(arr[3] == 3);
         assert(arr[4] == 14);
     }



More information about the Digitalmars-d-learn mailing list