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

Lance Bachmeier no at spam.net
Sun Aug 11 13:13:02 UTC 2024


On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:
> 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.

You may want to create a new thread about this in General. If 
it's going to get changed, now is the time as they're working on 
updates to Phobos, but they're not going to see this post.


More information about the Digitalmars-d-learn mailing list