Do you have a better way to remove element from a array?

mw mingwu at gmail.com
Sun Aug 11 06:04:08 UTC 2024


On Thursday, 5 February 2015 at 14:09:10 UTC, bearophile wrote:
> Tobias Pankrath:
>
>> Works as designed: 
>> http://dlang.org/phobos/std_algorithm.html#.remove
>
> Unfortunately it's one of the worst designed functions of 
> Phobos:
> https://issues.dlang.org/show_bug.cgi?id=10959
>
> Bye,
> bearophile

Hit this one today,

Has `removeAt` or `removeAtIndex` be added to the std lib?

BTW, for associative array, `remove()` is in-place; but here for 
std.algorithm.mutation.remove (*keyword*: mutation), one need to 
do

```
   array = array.remove(index);  // return a new container

   // v.s.
   aa.remove(key);  // return bool (if it's removed)
```

This in-consistence is really bad.




More information about the Digitalmars-d-learn mailing list