Why doesn't this throw?

Steven Schveighoffer schveiguy at yahoo.com
Fri May 25 07:53:15 PDT 2012


On Fri, 25 May 2012 08:59:47 -0400, Andrej Mitrovic  
<andrej.mitrovich at gmail.com> wrote:

> import std.algorithm;
> import std.stdio;
>
> void main()
> {
>     int[] a = [1, 2, 3];
>     a = a.remove(3);
>     writeln(a);
> }
>
> writes [1, 2]
>
> If I'd called a.remove with index 2 I would get the above result, but
> index 3 is clearly out of bounds, so why'd it remove the last element
> instead of throwing?

Because remove has a bug.

-Steve


More information about the Digitalmars-d-learn mailing list