Remove instance from array

Igor Shirkalin via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Jul 5 08:56:45 PDT 2017


On Wednesday, 5 July 2017 at 15:48:14 UTC, Jolly James wrote:
> On Wednesday, 5 July 2017 at 15:44:47 UTC, Igor Shirkalin wrote:
>> On Wednesday, 5 July 2017 at 15:30:08 UTC, Jolly James wrote:
>>>> WhatEver[] q = [];
>>>>
>>>> [...]
>>>>
>>>> auto i = new WhatEver();
>>>> q[] = i;
>>>>
>>>
>>> How does one remove that instance 'i'?
>>
>> What exactly do you want to remove? After a[]=i your array 
>> contain a lot of references to 'i'.
>
> I would like to know how works: removing
>  - the first
>  - and all
> references to 'i' inside the 'q'.

Perhaps, for all references to i it should look like:
a = a.filter!(a => a !is i).array;


More information about the Digitalmars-d-learn mailing list