Hi all,
I have dynamic array and I want to remove an element from it. All I have the index of the element to remove. And I want to the array should be in the same order. How to do it ?
Thread overview | |||||
---|---|---|---|---|---|
|
May 02, 2022 How to remove an element from a dynamic array with given index ? | ||||
---|---|---|---|---|
| ||||
May 02, 2022 Re: How to remove an element from a dynamic array with given index ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vinod K Chandran | On Mon, May 02, 2022 at 08:33:55PM +0000, Vinod K Chandran via Digitalmars-d-learn wrote: > Hi all, > I have dynamic array and I want to remove an element from it. All I > have the index of the element to remove. And I want to the array > should be in the same order. How to do it ? int[] data = [ 10, 20, 30, 40, 50 ]; data = data.remove(2); assert(data == [ 10, 20, 40, 50 ]); T -- Государство делает вид, что платит нам зарплату, а мы делаем вид, что работаем. |
May 02, 2022 Re: How to remove an element from a dynamic array with given index ? | ||||
---|---|---|---|---|
| ||||
Posted in reply to H. S. Teoh | On Monday, 2 May 2022 at 20:50:17 UTC, H. S. Teoh wrote:
>
>> should be in the same order. How to do it ?
>
> int[] data = [ 10, 20, 30, 40, 50 ];
> data = data.remove(2);
> assert(data == [ 10, 20, 40, 50 ]);
>
>
> T
>
Thanks a lot.
|
Copyright © 1999-2021 by the D Language Foundation