digitalmars.D.learn - Why doesn't this throw?
- Andrej Mitrovic (12/12) May 25 2012 import std.algorithm;
- Steven Schveighoffer (4/16) May 25 2012 Because remove has a bug.
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?
May 25 2012
On Fri, 25 May 2012 08:59:47 -0400, Andrej Mitrovic <andrej.mitrovich 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
May 25 2012