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

aberba karabutaworld at gmail.com
Wed Aug 21 08:00:04 UTC 2024


On Sunday, 11 August 2024 at 20:57:15 UTC, IchorDev wrote:
> On Sunday, 11 August 2024 at 06:04:08 UTC, mw wrote:
>> 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.
>
> One of them is part of DRuntime, and the other is a function 
> you can optionally import from Phobos. The fact that they do 
> not work the same way is not necessarily bad—they’re from 
> completely different places and serve completely different 
> purposes.

Naa, inconsistency is a bad design.


More information about the Digitalmars-d-learn mailing list