delete an element from an array

bearophile bearophileHUGS at lycos.com
Sun Oct 24 12:48:52 PDT 2010


spir:

> In my opinion, such non-obvious complications are good reasons to have seemingly trivial operations implemented as builtin routines. (and should throw error in case of failure)

std.algorithm.delete contains code like if(rEnd == range.length), so if you give it a signed integer coming from indexOf I think D converts it to unsigned... This is not good.

In an enhancement request in Bugzilla you may ask for a function that removes the first instance of an item equal to the given item (if it's not present it may raise an exception or return a boolean false). In your bug report you may link Python docs where it shows both ways to remove an item by index or by value. If you don't want to write this enhancement request, I may do it myself.

Bye,
bearophile


More information about the Digitalmars-d-learn mailing list